mirror of
https://github.com/project-zot/zot.git
synced 2026-06-17 21:17:58 +08:00
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:
@@ -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
|
||||
|
||||
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user