Skip to content

Commit 73fcd70

Browse files
fix(build, imageSpec): keep essential werf-stage-content-digest label
Signed-off-by: Aleksei Igrychev <aleksei.igrychev@palark.com>
1 parent 7f62e84 commit 73fcd70

File tree

2 files changed

+2
-8
lines changed

2 files changed

+2
-8
lines changed

Diff for: pkg/build/build_phase.go

-6
Original file line numberDiff line numberDiff line change
@@ -860,8 +860,6 @@ func (phase *BuildPhase) findAndFetchStageFromSecondaryStagesStorage(ctx context
860860
contentDigest, exist := stageDescCopy.Info.Labels[imagePkg.WerfStageContentDigestLabel]
861861
if exist {
862862
stg.SetContentDigest(contentDigest)
863-
} else if stg.Name() == stage.ImageSpec { // The content digest tag might be missing for the imageSpec stage (removed by the user).
864-
stg.SetContentDigest(stageDescCopy.Info.GetDigest())
865863
} else {
866864
panic(fmt.Sprintf("expected stage %q content digest label to be set!", stg.Name()))
867865
}
@@ -983,8 +981,6 @@ func (phase *BuildPhase) calculateStage(ctx context.Context, img *image.Image, s
983981
contentDigest, exist := stageDesc.Info.Labels[imagePkg.WerfStageContentDigestLabel]
984982
if exist {
985983
stageContentSig = contentDigest
986-
} else if stg.Name() == stage.ImageSpec { // The content digest tag might be missing for the imageSpec stage (removed by the user).
987-
stageContentSig = stageDesc.Info.GetDigest()
988984
} else {
989985
panic(fmt.Sprintf("expected stage %q content digest label to be set!", stg.Name()))
990986
}
@@ -1188,8 +1184,6 @@ func (phase *BuildPhase) atomicBuildStageImage(ctx context.Context, img *image.I
11881184
contentDigest, exist := stageDesc.Info.Labels[imagePkg.WerfStageContentDigestLabel]
11891185
if exist {
11901186
stg.SetContentDigest(contentDigest)
1191-
} else if stg.Name() == stage.ImageSpec { // The content digest tag might be missing for the imageSpec stage (removed by the user).
1192-
stg.SetContentDigest(stageDesc.Info.GetDigest())
11931187
} else {
11941188
panic(fmt.Sprintf("expected stage %q content digest label to be set!", stg.Name()))
11951189
}

Diff for: pkg/build/stage/image_spec.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const (
2222
labelTemplateImage = "image"
2323
labelTemplateProject = "project"
2424
labelTemplateDelimiter = "%"
25-
werfLabelsGlobalWarning = `The "werf" and "werf-parent-stage-id" labels cannot be removed within the imageSpec stage, as they are essential for the proper operation of host and container registry cleanup.
25+
werfLabelsGlobalWarning = `The "werf", "werf-stage-content-digest" and "werf.io/parent-stage-id" labels cannot be removed within the imageSpec stage, as they are essential for the proper operation of host and container registry cleanup.
2626
2727
If you need to remove all werf labels, use the werf export command. By default, this command removes all werf labels and fully detaches images from werf control, transferring host and container registry cleanup entirely to the user.
2828
@@ -207,7 +207,7 @@ func (s *ImageSpecStage) modifyLabels(ctx context.Context, labels, addLabels map
207207
continue
208208
}
209209

210-
if key == image.WerfLabel || key == image.WerfParentStageID {
210+
if key == image.WerfLabel || key == image.WerfParentStageID || key == image.WerfStageContentDigestLabel {
211211
if !keepEssentialWerfLabels {
212212
shouldPrintGlobalWarn = true
213213
}

0 commit comments

Comments
 (0)