Skip to content
Permalink
Browse files
fix: more correct handling of storage.ErrBrokenImage
Signed-off-by: Timofey Kirillov <timofey.kirillov@flant.com>
  • Loading branch information
distorhead committed Feb 18, 2022
1 parent bcf8205 commit fbbdd5471eaae770cdf5976bbd54979459d9b2af
Showing with 7 additions and 2 deletions.
  1. +2 −2 pkg/storage/manager/storage_manager.go
  2. +5 −0 pkg/storage/stages_storage.go
@@ -549,7 +549,7 @@ func (m *StorageManager) FetchStage(ctx context.Context, containerRuntime contai
return ErrShouldResetStagesStorageCache
}

if err == storage.ErrBrokenImage {
if storage.IsErrBrokenImage(err) {
logboek.Context(ctx).Error().LogF("Invalid stage %s image %q! Stage image is broken and is no longer available in the %s. Stages storage cache for project %q should be reset!\n", stg.LogDetailedName(), stg.GetImage().Name(), m.StagesStorage.String(), m.ProjectName)

logboek.Context(ctx).Error().LogF("Will mark image %q as rejected in the stages storage %s\n", stg.GetImage().Name(), m.StagesStorage.String())
@@ -994,7 +994,7 @@ func getStageDescription(ctx context.Context, projectName string, stageID image.
logboek.Context(ctx).Debug().LogF("Getting digest %q uniqueID %d stage info from %s...\n", stageID.Digest, stageID.UniqueID, stagesStorage.String())
stageDesc, err := stagesStorage.GetStageDescription(ctx, projectName, stageID.Digest, stageID.UniqueID)
switch {
case err == storage.ErrBrokenImage:
case storage.IsErrBrokenImage(err):
if opts.AllowStagesStorageCacheReset {
stageImageName := stagesStorage.ConstructStageImageName(projectName, stageID.Digest, stageID.UniqueID)

@@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"strings"

"github.com/werf/werf/pkg/container_runtime"
"github.com/werf/werf/pkg/image"
@@ -18,6 +19,10 @@ const (

var ErrBrokenImage = errors.New("broken image")

func IsErrBrokenImage(err error) bool {
return err != nil && strings.HasSuffix(err.Error(), ErrBrokenImage.Error())
}

type StagesStorage interface {
GetStagesIDs(ctx context.Context, projectName string) ([]image.StageID, error)
GetStagesIDsByDigest(ctx context.Context, projectName, digest string) ([]image.StageID, error)

0 comments on commit fbbdd54

Please sign in to comment.