Skip to content

Commit 762f9b7

Browse files
authored
fix: Fix checking dryRun when using Server Side Apply (argoproj#699)
* fix: properly check dryRun flag for server side apply Signed-off-by: Peter Jiang <peterjiang823@gmail.com> * Remove debug logging Signed-off-by: Peter Jiang <peterjiang823@gmail.com> --------- Signed-off-by: Peter Jiang <peterjiang823@gmail.com>
1 parent 1265e83 commit 762f9b7

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

pkg/sync/sync_context.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,12 +1013,12 @@ func (sc *syncContext) ensureCRDReady(name string) error {
10131013
})
10141014
}
10151015

1016-
func (sc *syncContext) shouldUseServerSideApply(targetObj *unstructured.Unstructured) bool {
1016+
func (sc *syncContext) shouldUseServerSideApply(targetObj *unstructured.Unstructured, dryRun bool) bool {
10171017
// if it is a dry run, disable server side apply, as the goal is to validate only the
10181018
// yaml correctness of the rendered manifests.
10191019
// running dry-run in server mode breaks the auto create namespace feature
10201020
// https://github.com/argoproj/argo-cd/issues/13874
1021-
if sc.dryRun {
1021+
if sc.dryRun || dryRun {
10221022
return false
10231023
}
10241024

@@ -1045,7 +1045,7 @@ func (sc *syncContext) applyObject(t *syncTask, dryRun, validate bool) (common.R
10451045
var message string
10461046
shouldReplace := sc.replace || resourceutil.HasAnnotationOption(t.targetObj, common.AnnotationSyncOptions, common.SyncOptionReplace)
10471047
force := sc.force || resourceutil.HasAnnotationOption(t.targetObj, common.AnnotationSyncOptions, common.SyncOptionForce)
1048-
serverSideApply := sc.shouldUseServerSideApply(t.targetObj)
1048+
serverSideApply := sc.shouldUseServerSideApply(t.targetObj, dryRun)
10491049
if shouldReplace {
10501050
if t.liveObj != nil {
10511051
// Avoid using `kubectl replace` for CRDs since 'replace' might recreate resource and so delete all CRD instances.

0 commit comments

Comments
 (0)