Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should support ServerSideApply=false sync-option #515

Open
sathieu opened this issue Mar 21, 2023 · 1 comment
Open

Should support ServerSideApply=false sync-option #515

sathieu opened this issue Mar 21, 2023 · 1 comment

Comments

@sathieu
Copy link
Contributor

sathieu commented Mar 21, 2023

Currently, SSA is opt-in either at application-level or at resource-level. However, to workaround argoproj/argo-cd#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.

ssaAnnotation := "ServerSideApply=true"

structuredMergeDiff := o.structuredMergeDiff ||
(config != nil && resource.HasAnnotationOption(config, syncOptAnnotation, ssaAnnotation))

@sathieu
Copy link
Contributor Author

sathieu commented Mar 21, 2023

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant