Skip to content

Commit

Permalink
fix(hooks): display ListenGerritStreamEvent error logs (#5399)
Browse files Browse the repository at this point in the history
  • Loading branch information
sguiheux authored Aug 27, 2020
1 parent b1053dd commit 5bfdc7c
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions engine/hooks/gerrit.go
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,10 @@ func ListenGerritStreamEvent(ctx context.Context, store cache.Store, v sdk.VCSCo

// Avoid that 2 hook uservice dispatch the same event
// Take the lock to dispatch an event
_, _ = store.Lock(lockKey, time.Minute, 100, 10)
locked, err := store.Lock(lockKey, time.Minute, 100, 15)
if err != nil {
log.Error(ctx, "unable to lock %s: %v", lockKey, err)
}

// compute md5
hasher := md5.New()
Expand All @@ -333,8 +336,10 @@ func ListenGerritStreamEvent(ctx context.Context, store cache.Store, v sdk.VCSCo
}

// release lock
if err := store.Unlock(lockKey); err == nil {
log.Error(ctx, "unable to unlock %s. Waiting lock timeout", lockKey)
if locked {
if err := store.Unlock(lockKey); err == nil {
log.Error(ctx, "unable to unlock %s: %v", lockKey, err)
}
}

if !b {
Expand Down

0 comments on commit 5bfdc7c

Please sign in to comment.