mirror of
https://github.com/argoproj/argo-cd.git
synced 2026-02-20 01:28:45 +01:00
fix: consider Replace/Force sync option on live resource annotations (#26110)
Signed-off-by: Alexandre Gaudreault <alexandre_gaudreault@intuit.com>
This commit is contained in:
committed by
GitHub
parent
3e26594009
commit
4d66a209d3
@@ -1272,8 +1272,8 @@ func (sc *syncContext) applyObject(t *syncTask, dryRun, validate bool) (common.R
|
||||
|
||||
var err error
|
||||
var message string
|
||||
shouldReplace := sc.replace || resourceutil.HasAnnotationOption(t.targetObj, common.AnnotationSyncOptions, common.SyncOptionReplace)
|
||||
force := sc.force || resourceutil.HasAnnotationOption(t.targetObj, common.AnnotationSyncOptions, common.SyncOptionForce)
|
||||
shouldReplace := sc.replace || resourceutil.HasAnnotationOption(t.targetObj, common.AnnotationSyncOptions, common.SyncOptionReplace) || (t.liveObj != nil && resourceutil.HasAnnotationOption(t.liveObj, common.AnnotationSyncOptions, common.SyncOptionReplace))
|
||||
force := sc.force || resourceutil.HasAnnotationOption(t.targetObj, common.AnnotationSyncOptions, common.SyncOptionForce) || (t.liveObj != nil && resourceutil.HasAnnotationOption(t.liveObj, common.AnnotationSyncOptions, common.SyncOptionForce))
|
||||
serverSideApply := sc.shouldUseServerSideApply(t.targetObj, dryRun)
|
||||
|
||||
// Check if we need to perform client-side apply migration for server-side apply
|
||||
|
||||
@@ -890,6 +890,7 @@ func TestSync_Replace(t *testing.T) {
|
||||
}{
|
||||
{"NoAnnotation", testingutils.NewPod(), testingutils.NewPod(), "apply"},
|
||||
{"AnnotationIsSet", withReplaceAnnotation(testingutils.NewPod()), testingutils.NewPod(), "replace"},
|
||||
{"AnnotationIsSetOnLive", testingutils.NewPod(), withReplaceAnnotation(testingutils.NewPod()), "replace"},
|
||||
{"LiveObjectMissing", withReplaceAnnotation(testingutils.NewPod()), nil, "create"},
|
||||
}
|
||||
|
||||
@@ -1031,6 +1032,7 @@ func TestSync_Force(t *testing.T) {
|
||||
{"NoAnnotation", testingutils.NewPod(), testingutils.NewPod(), "apply", false},
|
||||
{"ForceApplyAnnotationIsSet", withForceAnnotation(testingutils.NewPod()), testingutils.NewPod(), "apply", true},
|
||||
{"ForceReplaceAnnotationIsSet", withForceAndReplaceAnnotations(testingutils.NewPod()), testingutils.NewPod(), "replace", true},
|
||||
{"ForceReplaceAnnotationIsSetOnLive", testingutils.NewPod(), withForceAndReplaceAnnotations(testingutils.NewPod()), "replace", true},
|
||||
{"LiveObjectMissing", withReplaceAnnotation(testingutils.NewPod()), nil, "create", false},
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user