Skip to content

🌱 exponential retry on name resolution to registries #1576

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

Merged
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
30 changes: 20 additions & 10 deletions pkg/image/containerdregistry/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,26 @@ func (r *Registry) Pull(ctx context.Context, ref image.Reference) error {
return err
}

name, root, err := resolver.Resolve(ctx, ref.String())
if err != nil {
return fmt.Errorf("error resolving name for image ref %s: %v", ref.String(), err)
retryBackoff := wait.Backoff{
Copy link
Contributor

Choose a reason for hiding this comment

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

do we care about unit testing the retry? might require some refactoring to pass in a mock Resolve though, eh? =S

Copy link
Contributor

Choose a reason for hiding this comment

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

I'll leave it as a nit - otherwise lgtm =D

Copy link
Contributor Author

@grokspawn grokspawn Feb 11, 2025

Choose a reason for hiding this comment

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

Yeah, I was taken aback, honestly, at the lack of utest in the area. My practical test? Download 32 catalog combinations multiple times.

Duration: 1 * time.Second,
Factor: 1.0,
Jitter: 0.1,
Steps: 5,
}

var name string
var root ocispec.Descriptor
if err := retry.OnError(retryBackoff,
func(pullErr error) bool {
r.log.Warnf("Error resolving registry %q: %v. Retrying", ref.String(), pullErr)
return true
},
func() error {
name, root, err = resolver.Resolve(ctx, ref.String())
return err
},
); err != nil {
return fmt.Errorf("error resolving remote name %s: %v", ref.String(), err)
}
r.log.Debugf("resolved name: %s", name)

Expand All @@ -67,13 +84,6 @@ func (r *Registry) Pull(ctx context.Context, ref image.Reference) error {
return err
}

retryBackoff := wait.Backoff{
Duration: 1 * time.Second,
Factor: 1.0,
Jitter: 0.1,
Steps: 5,
}

if err := retry.OnError(retryBackoff,
func(pullErr error) bool {
if nonRetriablePullError.MatchString(pullErr.Error()) {
Expand Down
Loading