fix(sync): properly handle CommitAll errors in syncImage and skip failed temp sync dirs (#3567)

- Return CommitAll errors instead of ignoring them
- Skip ErrRepoNotFound from temp sync dirs to allow other tags to sync
- Each tag uses separate temp directory, so failures are isolated

Signed-off-by: Andrei Aaron <andreifdaaron@gmail.com>
This commit is contained in:
Andrei Aaron
2025-11-20 19:21:48 +02:00
committed by GitHub
parent 64829f9502
commit 69dd648d20
2 changed files with 8 additions and 2 deletions
+2
View File
@@ -131,6 +131,7 @@ func (onDemand *BaseOnDemand) syncReferrers(repo, subjectDigestStr string,
if errors.Is(err, zerr.ErrManifestNotFound) ||
errors.Is(err, zerr.ErrSyncImageFilteredOut) ||
errors.Is(err, zerr.ErrSyncImageNotSigned) ||
errors.Is(err, zerr.ErrRepoNotFound) ||
// some public registries may return 401 for not found.
errors.Is(err, zerr.ErrUnauthorizedAccess) {
continue
@@ -208,6 +209,7 @@ func (onDemand *BaseOnDemand) syncImage(repo, reference string, syncResult chan
if errors.Is(err, zerr.ErrManifestNotFound) ||
errors.Is(err, zerr.ErrSyncImageFilteredOut) ||
errors.Is(err, zerr.ErrSyncImageNotSigned) ||
errors.Is(err, zerr.ErrRepoNotFound) ||
// some public registries may return 401 for not found.
errors.Is(err, zerr.ErrUnauthorizedAccess) {
continue
+6 -2
View File
@@ -438,8 +438,10 @@ func (service *BaseService) SyncRepo(ctx context.Context, repo string) error {
if errors.Is(err, zerr.ErrSyncImageNotSigned) ||
errors.Is(err, zerr.ErrUnauthorizedAccess) ||
errors.Is(err, zerr.ErrMediaTypeNotSupported) ||
errors.Is(err, zerr.ErrManifestNotFound) {
// skip unsigned images or unsupported image mediatype
errors.Is(err, zerr.ErrManifestNotFound) ||
errors.Is(err, zerr.ErrRepoNotFound) {
// skip unsigned images, unsupported image mediatype, or temp sync dir issues
// ErrRepoNotFound from temp sync dir is skippable since each tag uses a different temp directory
continue
}
@@ -645,6 +647,8 @@ func (service *BaseService) syncImage(ctx context.Context, localRepo, remoteRepo
if err != nil {
service.log.Error().Str("errorType", common.TypeOf(err)).Str("repo", localRepo).
Err(err).Msg("failed to commit image")
return err
}
service.log.Info().Str("repo", localRepo).Str("reference", tag).Msg("successfully synced image")