Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retry the image pull once after 5 seconds #792

Merged
merged 1 commit into from
Oct 14, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions certification/internal/engine/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"github.com/google/go-containerregistry/pkg/crane"
"github.com/google/go-containerregistry/pkg/name"
"github.com/google/go-containerregistry/pkg/v1/cache"
"github.com/google/go-containerregistry/pkg/v1/remote"
log "github.com/sirupsen/logrus"
)

Expand Down Expand Up @@ -75,6 +76,7 @@ func (c *CraneEngine) ExecuteChecks(ctx context.Context) error {
authn.WithDockerConfig(c.Config.DockerConfig()),
),
),
retryOnceAfter(5 * time.Second),
acornett21 marked this conversation as resolved.
Show resolved Hide resolved
}

// pull the image and save to fs
Expand Down Expand Up @@ -585,3 +587,15 @@ func convertLabels(imageLabels map[string]string) []pyxis.Label {

return pyxisLabels
}

// retryOnceAfter is a crane option that retries once after t duration.
func retryOnceAfter(t time.Duration) crane.Option {
return func(o *crane.Options) {
o.Remote = append(o.Remote, remote.WithRetryBackoff(remote.Backoff{
Duration: t,
Factor: 1.0,
Jitter: 0.1,
Steps: 2,
}))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @komish, looks good for me, you change "0s -> 1s -> 4s" default strategy to "0s -> 5s", that could improve the situation in case of longer outages.

Maybe we could even keep the exponential strategy if the retry interval is large enough, something like "0s -> 5s -> 15s" strategy.

remote.Backoff{
			Duration: 5,
			Factor:   2.0,
			Jitter:   0.1,
			Steps:    3,
		}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the moment, I'll merge with 0s --> 5s, and if this proves not useful enough, we may consider a 3-step exponential. Keep us posted.

}
}