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

Empty objects vs. null objects cause repeated syncs #18213

Open
pgier opened this issue May 14, 2024 · 7 comments
Open

Empty objects vs. null objects cause repeated syncs #18213

pgier opened this issue May 14, 2024 · 7 comments
Labels
enhancement New feature or request

Comments

@pgier
Copy link

pgier commented May 14, 2024

Summary

When a config option is not set in the a kube manifest (e.g. statefulset) ArgoCD continually tries to re-sync the object because it sees a diff between an empty and undefined object.

Motivation

I have a statefulset that does not define the resources section. ArgoCD continually tries to sync the object because Kubernetes automatically injects an empty object.
Screenshot 2024-05-14 at 7 50 11 AM

Proposal

The diff calculator should ignore the difference between an empty and null object in a kubernetes resource field.

Related

#15554

@pgier pgier added the enhancement New feature or request label May 14, 2024
@blakeromano
Copy link

Is this with Server Side Diff on or off? I would imagine looking at https://argo-cd.readthedocs.io/en/stable/user-guide/diff-strategies/#server-side-diff may help with scenarios like this. I don't believe there's plans to make the default Server Side Diff until a 3.x release but this may be something you want to take a look at...

@evanrich
Copy link

Is this with Server Side Diff on or off? I would imagine looking at https://argo-cd.readthedocs.io/en/stable/user-guide/diff-strategies/#server-side-diff may help with scenarios like this. I don't believe there's plans to make the default Server Side Diff until a 3.x release but this may be something you want to take a look at...

i just tried enabling that and it didn't seem to make a difference on my environment

@evanrich
Copy link

evanrich commented May 15, 2024

FWIW, this works for me for the "resources: {}" diff

      ignoreDifferences:
      - group: apps
        kind: Deployment
        jqPathExpressions:
        - '.spec.template.spec.containers[].resources'
      - group: apps
        kind: StatefulSet
        jqPathExpressions:
        - '.spec.template.spec.containers[].resources'

@pgier
Copy link
Author

pgier commented May 22, 2024

Is this with Server Side Diff on or off?

I haven't set any options for server side diff in the application or the main configmap, so it should be off.
On the application I only have these sync options set.

        syncOptions:
        - CreateNamespace=true
        - ServerSideApply=true

@evanrich Thanks, I was hoping I wouldn't have to ignore resources for the cases where there are real differences, but I can probably use that for now.

@pgier
Copy link
Author

pgier commented May 22, 2024

This is very strange, I have multiple clusters with basically the same configuration.
AWS EKS (same region)
Kube version: 1.28.8
ArgoCD version: v2.10.7+b060053

Same application (external-secrets) deployed to both clusters.
One of the clusters shows a diff on the empty vs. null resources and continually tries to resync.
The other cluster shows the same difference if you look at the live manifest vs. desired manifest, but does not display anything on the diff tab and does not try to re-sync.

I verified that on the cluster which is not showing a diff and therefore not syncing has resources: {} in the live manifest and nothing defined for resources in the desired manifest. So for some reason this cluster is successfully ignoring that difference even though I didn't configure any ignoreDifferences.

So same application running in the same version of Argo and Kubernetes seems to sometimes ignore this difference and sometimes not ignore it.

@batazor
Copy link

batazor commented May 24, 2024

Noticed this problem with version 2.11 quite a lot

Adding this to ignoreDifferences doesn't seem like a good idea to me

@javydekoning
Copy link

This has suddenly emerged in my k3s cluster as well.

Kubernetes version: v1.30.0+k3s1
Argo: v2.11.2

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

No branches or pull requests

5 participants