Skip to content

[registry facade] Don't retry requests with error messages that were successful #20889

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 1 commit into from
Jun 9, 2025
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion components/blobserve/pkg/blobserve/refstore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ func TestBlobFor(t *testing.T) {
refDescriptor: provideDescriptor,
},
Expectation: Expectation{
Error: "cannot fetch manifest: " + hashManifest + " not found",
Error: "failed to fetch manifest: " + hashManifest + " not found",
},
},
{
Expand Down
31 changes: 28 additions & 3 deletions components/registry-facade/pkg/registry/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,10 @@ func DownloadConfig(ctx context.Context, fetch FetcherFunc, ref string, desc oci
rc, err = fetcher.Fetch(ctx, desc)
if err != nil {
log.WithError(err).Warn("cannot fetch config")
return false, nil // retry
if retryableError(err) {
return false, nil // retry
}
return false, err
}
defer rc.Close()
}
Expand Down Expand Up @@ -467,7 +470,10 @@ func DownloadManifest(ctx context.Context, fetch FetcherFunc, desc ociv1.Descrip
rc, err = fetcher.Fetch(ctx, desc)
if err != nil {
log.WithError(err).Warn("cannot fetch manifest")
return false, nil // retry
if retryableError(err) {
return false, nil // retry
}
return false, err
}
mediaType = desc.MediaType
}
Expand Down Expand Up @@ -521,7 +527,10 @@ func DownloadManifest(ctx context.Context, fetch FetcherFunc, desc ociv1.Descrip
rc, err = fetcher.Fetch(ctx, md)
if err != nil {
log.WithError(err).Warn("cannot download config")
return false, nil // retry
if retryableError(err) {
return false, nil // retry
}
return false, err
}
rdesc = &md
inpt, err = io.ReadAll(rc)
Expand Down Expand Up @@ -587,3 +596,19 @@ func (mh *manifestHandler) putManifest(w http.ResponseWriter, r *http.Request) {
func (mh *manifestHandler) deleteManifest(w http.ResponseWriter, r *http.Request) {
respondWithError(w, distv2.ErrorCodeManifestUnknown)
}

func retryableError(err error) bool {
if err == nil {
return false
}
if errors.Is(err, errdefs.ErrNotFound) || errors.Is(err, errdefs.ErrInvalidArgument) {
return false
}
if strings.Contains(err.Error(), "not found") ||
strings.Contains(err.Error(), "invalid argument") ||
strings.Contains(err.Error(), "not implemented") ||
strings.Contains(err.Error(), "unsupported media type") {
return false
}
Comment on lines +607 to +612
Copy link
Contributor

Choose a reason for hiding this comment

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

Question, non-blocking:
@geropl how did you come up with this list? I ask because depending on the answer, we might want to include others like to cover scenarios like 401 (Unauthorized) and 403 (Forbidden).

Double checking workspace start prior to adding approval.

Copy link
Member Author

Choose a reason for hiding this comment

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

@kylos101 Yeah, good call. After sleeping over it, I think it should have been the reverse: default to false, and only retry the exact errors we saw as 500 in the logs. Might even be worth swapping that now... 🤔

return true
}
Loading