Skip to content

Commit

Permalink
updated timeout to be more verbose
Browse files Browse the repository at this point in the history
  • Loading branch information
imuni4fun committed Feb 22, 2024
1 parent 17c1c87 commit 8b54915
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/remoteimageasync/puller.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,18 @@ func RunPullerLoop(
go func() {
klog.V(2).Infof("%s.RunPullerLoop(): asked to pull image %s with timeout %v\n",
prefix, ses.image, ses.timeout)
ctxCombined, cancelDontCare := context.WithTimeout(ctx, ses.timeout) // combine timeout and shut down signal into one
defer cancelDontCare() // IF we exit, this no longer matters. calling to satisfy linter.
ctxAsyncPullTimeoutOrShutdown, cancelDontCare := context.WithTimeout(ctx, ses.timeout) // combine session timeout and shut down signal into one
defer cancelDontCare() // IF we exit, this no longer matters. calling to satisfy linter.
pullStart := time.Now()
pullErr := ses.puller.Pull(ctxCombined) //NOTE: relying existing tests or history to verify behavior, asyncPull just wraps it
pullErr := ses.puller.Pull(ctxAsyncPullTimeoutOrShutdown)
// update fields on session before declaring done
select {
case <-ctx.Done(): // shutting down
ses.isTimedOut = false
ses.err = fmt.Errorf("%s.RunPullerLoop(): shutting down", prefix)
klog.V(2).Infof(ses.err.Error())
metrics.OperationErrorsCount.WithLabelValues("pull-async-shutdown").Inc()
case <-ctxCombined.Done(): // timeout or shutdown
case <-ctxAsyncPullTimeoutOrShutdown.Done(): // timeout or shutdown
ses.isTimedOut = true
ses.err = fmt.Errorf("%s.RunPullerLoop(): async pull exceeded timeout of %v for image %s", prefix, ses.timeout, ses.image)
klog.V(2).Infof(ses.err.Error())
Expand Down

0 comments on commit 8b54915

Please sign in to comment.