Skip to content

Commit

Permalink
Merge branch 'main' into fix/tests-ctx
Browse files Browse the repository at this point in the history
  • Loading branch information
plyr4 committed Sep 20, 2024
2 parents aeea730 + db0fc08 commit 214efa9
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions cmd/vela-worker/operate.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,19 @@ func (w *Worker) operate(ctx context.Context) error {

// spawn goroutine for phoning home
executors.Go(func() error {
// five second ticker for signal handling
ticker := time.NewTicker(5 * time.Second)
defer ticker.Stop()

// initialize timer for check-in
timer := time.After(0)

for {
select {
case <-gctx.Done():
logrus.Info("completed looping on worker registration")
return nil
default:
case <-timer:
// check in attempt loop
for {
// register or update the worker
Expand Down Expand Up @@ -145,9 +152,12 @@ func (w *Worker) operate(ctx context.Context) error {
return err
}

// sleep for the configured time
time.Sleep(w.Config.CheckIn)
// set timer to next check in
timer = time.After(w.Config.CheckIn)
}

// five second ticker
<-ticker.C
}
})

Expand Down

0 comments on commit 214efa9

Please sign in to comment.