@@ -291,18 +291,7 @@ func UpdateApplication(updateConf *UpdateConfiguration, state *SyncIterationStat
291
291
continue
292
292
}
293
293
294
- // If the user has specified digest as update strategy, but the running
295
- // image is configured to use a tag and no digest, we need to set an
296
- // initial dummy digest, so that tag.Equals() will return false.
297
- // TODO: Fix this. This is just a workaround.
298
- if vc .Strategy == image .StrategyDigest {
299
- if ! updateableImage .ImageTag .IsDigest () {
300
- log .Tracef ("Setting dummy digest for image %s" , updateableImage .GetFullNameWithTag ())
301
- updateableImage .ImageTag .TagDigest = "dummy"
302
- }
303
- }
304
-
305
- if needsUpdate (updateableImage , applicationImage , latest ) {
294
+ if needsUpdate (updateableImage , applicationImage , latest , vc .Strategy ) {
306
295
appImageWithTag := applicationImage .WithTag (latest )
307
296
appImageFullNameWithTag := appImageWithTag .GetFullNameWithTag ()
308
297
@@ -406,7 +395,17 @@ func UpdateApplication(updateConf *UpdateConfiguration, state *SyncIterationStat
406
395
return result
407
396
}
408
397
409
- func needsUpdate (updateableImage * image.ContainerImage , applicationImage * image.ContainerImage , latest * tag.ImageTag ) bool {
398
+ func needsUpdate (updateableImage * image.ContainerImage , applicationImage * image.ContainerImage , latest * tag.ImageTag , strategy image.UpdateStrategy ) bool {
399
+ if strategy == image .StrategyDigest {
400
+ if updateableImage .ImageTag == nil {
401
+ return true
402
+ }
403
+ // When using digest strategy, consider the digest even if the current image
404
+ // was referenced by tag. If either digest is missing or differs, we want an update.
405
+ if ! updateableImage .ImageTag .IsDigest () || updateableImage .ImageTag .TagDigest != latest .TagDigest {
406
+ return true
407
+ }
408
+ }
410
409
// If the latest tag does not match image's current tag or the kustomize image is different, it means we have an update candidate.
411
410
return ! updateableImage .ImageTag .Equals (latest ) || applicationImage .KustomizeImage != nil && applicationImage .DiffersFrom (updateableImage , false )
412
411
}
0 commit comments