Skip to content

Commit 889af4b

Browse files
authored
fix: remove dummy digest and add comparison logic (#1161)
Signed-off-by: chansuke <moonset20@gmail.com>
1 parent 398db53 commit 889af4b

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

pkg/argocd/update.go

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -277,18 +277,7 @@ func UpdateApplication(updateConf *UpdateConfiguration, state *SyncIterationStat
277277
continue
278278
}
279279

280-
// If the user has specified digest as update strategy, but the running
281-
// image is configured to use a tag and no digest, we need to set an
282-
// initial dummy digest, so that tag.Equals() will return false.
283-
// TODO: Fix this. This is just a workaround.
284-
if vc.Strategy == image.StrategyDigest {
285-
if !updateableImage.ImageTag.IsDigest() {
286-
log.Tracef("Setting dummy digest for image %s", updateableImage.GetFullNameWithTag())
287-
updateableImage.ImageTag.TagDigest = "dummy"
288-
}
289-
}
290-
291-
if needsUpdate(updateableImage, applicationImage, latest) {
280+
if needsUpdate(updateableImage, applicationImage, latest, vc.Strategy) {
292281
appImageWithTag := applicationImage.WithTag(latest)
293282
appImageFullNameWithTag := appImageWithTag.GetFullNameWithTag()
294283

@@ -392,7 +381,17 @@ func UpdateApplication(updateConf *UpdateConfiguration, state *SyncIterationStat
392381
return result
393382
}
394383

395-
func needsUpdate(updateableImage *image.ContainerImage, applicationImage *image.ContainerImage, latest *tag.ImageTag) bool {
384+
func needsUpdate(updateableImage *image.ContainerImage, applicationImage *image.ContainerImage, latest *tag.ImageTag, strategy image.UpdateStrategy) bool {
385+
if strategy == image.StrategyDigest {
386+
if updateableImage.ImageTag == nil {
387+
return true
388+
}
389+
// When using digest strategy, consider the digest even if the current image
390+
// was referenced by tag. If either digest is missing or differs, we want an update.
391+
if !updateableImage.ImageTag.IsDigest() || updateableImage.ImageTag.TagDigest != latest.TagDigest {
392+
return true
393+
}
394+
}
396395
// If the latest tag does not match image's current tag or the kustomize image is different, it means we have an update candidate.
397396
return !updateableImage.ImageTag.Equals(latest) || applicationImage.KustomizeImage != nil && applicationImage.DiffersFrom(updateableImage, false)
398397
}

0 commit comments

Comments
 (0)