Skip to content

Commit

Permalink
only pop from queue once
Browse files Browse the repository at this point in the history
  • Loading branch information
ecrupper committed Aug 15, 2024
1 parent c3f4990 commit 0d846bf
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions cmd/vela-worker/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,22 +65,24 @@ func (w *Worker) exec(index int, config *api.Worker) error {
return err
}

// capture an item from the queue
item, err = w.Queue.Pop(context.Background(), worker.GetRoutes())
if err != nil {
logrus.Errorf("queue pop failed: %v", err)

// returning immediately on queue pop fail will attempt
// to pop in quick succession, so we honor the configured timeout
time.Sleep(w.Config.Queue.Timeout)

// returning nil to avoid unregistering the worker on pop failure;
// sometimes queue could be unavailable due to blip or maintenance
return nil
}
// capture an item from the queue only on first loop iteration (failures here return nil)
if i == 0 {
item, err = w.Queue.Pop(context.Background(), worker.GetRoutes())
if err != nil {
logrus.Errorf("queue pop failed: %v", err)

// returning immediately on queue pop fail will attempt
// to pop in quick succession, so we honor the configured timeout
time.Sleep(w.Config.Queue.Timeout)

// returning nil to avoid unregistering the worker on pop failure;
// sometimes queue could be unavailable due to blip or maintenance
return nil
}

if item == nil {
return nil
if item == nil {
return nil
}
}

// retrieve a build token from the server to setup the execBuildClient
Expand Down

0 comments on commit 0d846bf

Please sign in to comment.