gitops-engine
gitops-engine copied to clipboard
Should support ServerSideApply=false sync-option
Currently, SSA is opt-in either at application-level or at resource-level. However, to workaround https://github.com/argoproj/argo-cd/issues/11143, I need to use ServerSideApply=false
for a specific resource while SSA is enabled for all other resources.
Currently it does app-enabled || resource-enabled
.
https://github.com/argoproj/gitops-engine/blob/98ccd3d43fd9f4dbc3f6610b9701fbf56be53ded/pkg/diff/diff.go#L91
https://github.com/argoproj/gitops-engine/blob/98ccd3d43fd9f4dbc3f6610b9701fbf56be53ded/pkg/diff/diff.go#L98-L99
Quick and dirty patch:
diff --git a/pkg/diff/diff.go b/pkg/diff/diff.go
--- pkg/diff/diff.go
+++ pkg/diff/diff.go
@@ -87,17 +87,21 @@
// dependency with the kube package that blocks the usage of constants
// from common package. common package needs to be refactored and exclude
// dependency from kube.
syncOptAnnotation := "argocd.argoproj.io/sync-options"
- ssaAnnotation := "ServerSideApply=true"
+ ssaEnabledAnnotation := "ServerSideApply=true"
+ ssaDisabledAnnotation := "ServerSideApply=false"
// structuredMergeDiff is mainly used as a feature flag to enable
// calculating diffs using the structured-merge-diff library
// used in k8s while performing server-side applies. It checks the
// given diff Option or if the desired state resource has the
// Server-Side apply sync option annotation enabled.
structuredMergeDiff := o.structuredMergeDiff ||
- (config != nil && resource.HasAnnotationOption(config, syncOptAnnotation, ssaAnnotation))
+ (config != nil && resource.HasAnnotationOption(config, syncOptAnnotation, ssaEnabledAnnotation))
+ if structuredMergeDiff && config != nil && resource.HasAnnotationOption(config, syncOptAnnotation, ssaDisabledAnnotation) {
+ structuredMergeDiff = false
+ }
if structuredMergeDiff {
r, err := StructuredMergeDiff(config, live, o.gvkParser, o.manager)
if err != nil {
return nil, fmt.Errorf("error calculating structured merge diff: %w", err)