Skip to content
Permalink
Browse files
fix(quay): ignore TAG_EXPIRED broken tags
  • Loading branch information
distorhead committed Jan 26, 2022
1 parent 1ef7073 commit c302c05fa607a86abf13027ff6f25a272155053e
Showing with 20 additions and 4 deletions.
  1. +1 −1 pkg/docker_registry/api.go
  2. +12 −0 pkg/docker_registry/default.go
  3. +1 −1 pkg/docker_registry/generic_api.go
  4. +5 −1 pkg/docker_registry/quay.go
  5. +1 −1 pkg/storage/repo_stages_storage.go
@@ -81,7 +81,7 @@ func (api *api) IsRepoImageExists(ctx context.Context, reference string) (bool,

func (api *api) TryGetRepoImage(ctx context.Context, reference string) (*image.Info, error) {
if imgInfo, err := api.GetRepoImage(ctx, reference); err != nil {
if IsBlobUnknownError(err) || IsManifestUnknownError(err) || IsNameUnknownError(err) || IsHarbor404Error(err) {
if IsBlobUnknownError(err) || IsManifestUnknownError(err) || IsNameUnknownError(err) || IsHarbor404Error(err) || IsQuayTagExpiredErr(err) {
// TODO: 1. auto reject images with manifest-unknown or blob-unknown errors
// TODO: 2. why TryGetRepoImage for rejected image records gives manifest-unknown errors?
// TODO: 3. make sure werf never ever creates rejected image records for name-unknown errors.
@@ -40,6 +40,12 @@ func (r *defaultImplementation) Tags(ctx context.Context, reference string) ([]s
logboek.Context(ctx).Error().LogF("WARNING: to instruct werf to use harbor driver.\n")
}

if IsQuayTagExpiredErr(err) && r.Implementation != QuayImplementationName {
logboek.Context(ctx).Error().LogF("WARNING: Detected error specific for quay container registry implementation!\n")
logboek.Context(ctx).Error().LogF("WARNING: Use --repo-container-registry=quay option (or WERF_CONTAINER_REGISTRY env var)\n")
logboek.Context(ctx).Error().LogF("WARNING: to instruct werf to use quay driver.\n")
}

return tags, err
}

@@ -60,6 +66,12 @@ func (r *defaultImplementation) TryGetRepoImage(ctx context.Context, reference s
logboek.Context(ctx).Error().LogF("WARNING: to instruct werf to use harbor driver.\n")
}

if IsQuayTagExpiredErr(err) && r.Implementation != QuayImplementationName {
logboek.Context(ctx).Error().LogF("WARNING: Detected error specific for quay container registry implementation!\n")
logboek.Context(ctx).Error().LogF("WARNING: Use --repo-container-registry=quay option (or WERF_CONTAINER_REGISTRY env var)\n")
logboek.Context(ctx).Error().LogF("WARNING: to instruct werf to use quay driver.\n")
}

return info, err
}

@@ -49,7 +49,7 @@ func (api *genericApi) GetRepoImageConfigFile(ctx context.Context, reference str
for _, mirrorReference := range mirrorReferenceList {
config, err := api.getRepoImageConfigFile(ctx, mirrorReference)
if err != nil {
if IsBlobUnknownError(err) || IsManifestUnknownError(err) || IsNameUnknownError(err) || IsHarbor404Error(err) {
if IsBlobUnknownError(err) || IsManifestUnknownError(err) || IsNameUnknownError(err) || IsHarbor404Error(err) || IsQuayTagExpiredErr(err) {
continue
}

@@ -25,7 +25,11 @@ func NewQuayRepositoryNotFoundErr(err error) QuayRepositoryNotFoundErr {
}

func IsQuayRepositoryNotFoundErr(err error) bool {
return strings.Contains(err.Error(), quayRepositoryNotFoundErrPrefix)
return err != nil && strings.Contains(err.Error(), quayRepositoryNotFoundErrPrefix)
}

func IsQuayTagExpiredErr(err error) bool {
return err != nil && strings.Contains(err.Error(), "TAG_EXPIRED: ")
}

var quayPatterns = []string{"^quay\\.io", "^quay\\..*\\.com"}
@@ -273,7 +273,7 @@ func (storage *RepoStagesStorage) GetStageDescription(ctx context.Context, proje
return nil, nil
}

if docker_registry.IsBlobUnknownError(err) || docker_registry.IsHarbor404Error(err) {
if docker_registry.IsBlobUnknownError(err) || docker_registry.IsHarbor404Error(err) || docker_registry.IsQuayTagExpiredErr(err) {
return nil, ErrBrokenImage
}

0 comments on commit c302c05

Please sign in to comment.