argo-cd icon indicating copy to clipboard operation
argo-cd copied to clipboard

Unable to disable auto-sync

Open sadovnikov opened this issue 4 years ago • 25 comments

Argo CD version:

Describe the bug

With app-of-apps pattern, when syncPolicy of a child application changes from "automated" to empty, Argo does not spot the difference. The child application remains in auto-sync mode, although it's desired manifest in the parent app changes

To Reproduce

  • Create an application, which creates another application with auto-sync policy
  syncPolicy:
    automated: {}
  • After everything is synchronized change policy to
  syncPolicy: {}

Expected behavior

Synchronization policy of the child application changes. However, it remains auto-sync. No Diff is spotted in spite of different live and desired manifests

Screenshots

With these live and desired manifests, the Diff tab is empty

image

image

Version

Taken from UI

v1.6.1+159674e

Note: we also spotted #3815. Seems treating of default or boolean values of syncPolicy has changed in v1.6

sadovnikov avatar Jul 03 '20 09:07 sadovnikov

Hi @sadovnikov, I couldn't reproduce this issue, but maybe I did the wrong steps to reproduce it. I did the following:

  • I created a repo containing a single application.yaml with the following contents:
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
  name: test-app
  namespace: argocd
spec:
  destination:
    namespace: test
    server: https://kubernetes.default.svc
  project: default
  source:
    path: kustomize-guestbook
    repoURL: https://github.com/jannfis/argocd-example-apps
    targetRevision: HEAD
  syncPolicy:
    automated: {}
  • I then created an application parent using ArgoCD UI, and specifying above mentioned repo as its source. This creates the app-of-apps pattern, with parent as parent and test-app as child. parent has no automatic sync policy.
  • Once I sync parent, test-app resource is created and immediately syncs due to automatic sync policy
  • I changed sync policy of test-app to syncPolicy: {} and commited to repository
  • After a refresh, parent becomes out of sync
  • Once I sync parent, it reconciles the updated manifest for test-app and I can see that automatic sync policy for test-app is disabled

Did I miss something?

jannfis avatar Jul 03 '20 14:07 jannfis

Hi @jannfis, I created https://github.com/sadovnikov/argocd-tests/tree/master/github-3895 to reproduce the bug, but it's not reproducible anymore. Neither I can reproduce it with the original repositories ;( I'll re-open the issue if I find a way to reproduce it. Thank you!

sadovnikov avatar Jul 06 '20 12:07 sadovnikov

Hi everyone, I'm facing the same issue, It start when i tried to run a rollback from the UI and got the following error : Screen Shot 2021-08-19 at 14 17 16 Then, i chose one of the old deployment to rollback, got prompt if i want to disable the auto-sync, clicked yes and got the following error : Screen Shot 2021-08-19 at 14 18 36

When trying to disable the auto-sync from the UI OR from the cli, nothing really happen.

https://user-images.githubusercontent.com/31075689/130060627-c765c598-a04c-477a-bbda-af10c4c87659.mov

{
    "Version": "v2.0.3+8d2b13d",
    "BuildDate": "2021-05-27T17:38:37Z",
    "GitCommit": "8d2b13d733e1dff7d1ad2c110ed31be4804406e2",
    "GitTreeState": "clean",
    "GoVersion": "go1.16",
    "Compiler": "gc",
    "Platform": "linux/amd64",
    "KsonnetVersion": "v0.13.1",
    "KustomizeVersion": "v3.9.4 2021-02-09T19:22:10Z",
    "HelmVersion": "v3.5.1+g32c2223",
    "KubectlVersion": "v0.20.4",
    "JsonnetVersion": "v0.17.0"
}

dorroddorrod avatar Aug 19 '21 11:08 dorroddorrod

@sadovnikov Would you mind to re-open this issue ?

dorroddorrod avatar Aug 19 '21 12:08 dorroddorrod

kubectl -n <namespace> patch --type='merge' application <app-name> -p "{\"spec\":{\"syncPolicy\":null}}"

cheddarwhizzy avatar Sep 08 '21 21:09 cheddarwhizzy

I'm having this problem too.

I'm trying it from the UI (buttons), modifying the manifest, the kubectl patch does not work either.

I'm under the impression that this is something intermittent. I think it was working a day or two ago, but now it's not.

Here is my server version

{ "Version": "v2.0.4+0842d44", "BuildDate": "2021-06-23T01:27:53Z", "GitCommit": "0842d448107eb1397b251e63ec4d4bc1b4efdd6e", "GitTreeState": "clean", "GoVersion": "go1.16", "Compiler": "gc", "Platform": "linux/amd64", "KsonnetVersion": "v0.13.1", "KustomizeVersion": "v3.9.4 2021-02-09T19:22:10Z", "HelmVersion": "v3.5.1+g32c2223", "KubectlVersion": "v0.20.4", "JsonnetVersion": "v0.17.0" }

ThoughtHopper avatar Sep 10 '21 15:09 ThoughtHopper

Created ticket to improve auto-sync button behavior: https://github.com/argoproj/argo-cd/issues/7197

alexmt avatar Sep 10 '21 16:09 alexmt

is there any update about this bug?

converge avatar Sep 21 '22 16:09 converge

We are also experiencing this issue, what is the current status on this?

tommyalatalo avatar Dec 19 '22 16:12 tommyalatalo

Re-opening this as people reporting issue again.

jannfis avatar Dec 19 '22 16:12 jannfis

Any news?

I'm experiencing the same issue.

To disable the sync in the YAML manifest I set syncPolicy: {} but I would like to keep the syncOption, and today is impossible to have both.

https://argo-cd.readthedocs.io/en/stable/user-guide/sync-options/#fail-the-sync-if-a-shared-resource-is-found

syncPolicy:
    syncOptions:
      - FailOnSharedResource=true

thiagolsfortunato avatar Jan 20 '23 15:01 thiagolsfortunato

I'm facing the similar problem that I cannot disable auto-snyc (nor pruning and self heal) of an application resource via the UI. It seems to me that argoCD is overwriting these changes immediately as it tries to sync and auto-heal again - which Im trying to disable! So the UI buttons must get around the self-healing and auto-syncing process to be able to work...

adrian-sturm avatar Mar 15 '23 10:03 adrian-sturm

Update: For my problem (and i figure it might resolve the OPs problem as well) the issue was that in my app-of-apps pattern, the root-application was configured with self-heal=true, causing changes to the child-apps to be "healed" even though the child apps had a different (or no) sync-policy configured. So now my setup is: root-app: syncPolicy: automated # so new apps are auto-detected and deployed prune: true # so removed apps get deleted and selfHeal: false # so changes to child-apps (e.g. via the UI) do not trigger an auto sync

I hope this helps someone out there as well!

adrian-sturm avatar Mar 16 '23 10:03 adrian-sturm

I want to override sync policy from CLI and I also fail miserably. I tried the approach proposed by @adrian-sturm, but with no result. I tried disabling syncing at all, also with no result. From UI the situation is the same. Additionally, I don't get any error messages, argo just keeps bringing back the original configuration.

  1. Parent application yaml and original status:

    destination:                                                                 
      namespace: krowa                                                           
      server: https://kubernetes.default.svc                                     
    project: default                                                             
    source:                                                                      
      helm:                                                                      
        valueFiles:                                                              
        - environments/dev.yaml                                                  
      path: argocd/krowa-apps                                                    
      repoURL: <redacted>                                                        
      targetRevision: HEAD                                                       
    syncPolicy:                                                                  
      automated:                                                                 
        prune: true                                                              
        selfHeal: true                                                           
    
    $ argocd app get krowa-parent
    Name:               argo/krowa-parent
    Project:            default
    Server:             https://kubernetes.default.svc
    Namespace:          krowa
    URL:                <redacted>
    Repo:               <redacted>
    Target:             HEAD
    Path:               argocd/krowa-apps
    Helm Values:        environments/dev.yaml
    SyncWindow:         Sync Allowed
    Sync Policy:        Automated (Prune)
    Sync Status:        Synced to HEAD (5519559)
    Health Status:      Healthy
    
    GROUP        KIND         NAMESPACE     NAME             STATUS     HEALTH  HOOK  MESSAGE
                 Namespace    krowa         krowa            Succeeded  Synced        namespace/krowa unchanged
    argoproj.io  Application  argo          child-app        Synced                   application.argoproj.io/child-app configured
                 Namespace                  krowa            Synced
    
  2. I edited parent app and I commented out whole syncPolicy section:

    $ argocd app edit krowa-parent
    
     # Please edit the object below. Lines beginning with a '#' will be ignored,
     # and an empty file will abort the edit. If an error occurs while saving this file will be
     # reopened with the relevant failures."
    
     destination:
       namespace: krowa
       server: https://kubernetes.default.svc
     project: default
     source:
       helm:
         valueFiles:
         - environments/dev.yaml
       path: argocd/krowa-apps
       repoURL: <redacted>
       targetRevision: HEAD
    # syncPolicy:
    #   automated:
    #     prune: true
    #     selfHeal: true
    
  3. Check app once again

    $ argocd app get krowa-parent
    Name:               argo/krowa-parent
    Project:            default
    Server:             https://kubernetes.default.svc
    Namespace:          krowa
    URL:                <redacted>
    Repo:               <redacted>
    Target:             HEAD
    Path:               argocd/krowa-apps
    Helm Values:        environments/dev.yaml
    SyncWindow:         Sync Allowed
    Sync Policy:        Automated (Prune)
    Sync Status:        Synced to HEAD (5519559)
    Health Status:      Healthy
    
    GROUP        KIND         NAMESPACE     NAME             STATUS     HEALTH  HOOK  MESSAGE
                 Namespace    krowa         krowa            Succeeded  Synced        namespace/krowa unchanged
    argoproj.io  Application  argo          child-app        Synced                   application.argoproj.io/child-app configured
                 Namespace                  krowa            Synced
    
    
  4. Running argocd app set krowa-parent --sync-policy="none" has no effect.

  5. Changes in UI are also immediately brought back to the original settings.

  6. Argo CD Server version

    {
    "Version": "v2.6.3+e05298b",
    "BuildDate": "2023-02-27T14:40:19Z",
    "GitCommit": "e05298b9c6ab8610104271fa8491f019fee3c587",
    "GitTreeState": "clean",
    "GoVersion": "go1.18.10",
    "Compiler": "gc",
    "Platform": "linux/amd64",
    "KustomizeVersion": "v4.5.7 2022-08-02T16:35:54Z",
    "HelmVersion": "v3.10.3+g835b733",
    "KubectlVersion": "v0.24.2",
    "JsonnetVersion": "v0.19.1"
    }
    

I'd really appreciate some help :)

olastefaniak avatar Apr 27 '23 15:04 olastefaniak

@olastefaniak I assume you are using the app-of-apps pattern as well and "krowa-parent" is the root application resource? Commenting out the sync policy likely results in argocd using the default sync policy, which I could not find in the docs but by the behavior you describe it might be "automated" anyways. As long as "self-heal" is activated in the deployed resource (aka the yaml found in your k8s cluster), argocd will continue to overwrite any changes with the status described in your repository.

Have you tried disabling "self-heal" in your repository (target-manifest in argocd-terms)? And if so, did you check that this change is actually deployed in the cluster?

If that does not fix the situation, there has to be some other resource (e.g. application or applicationset) that references your "krowa-parent" app and has self-heal enabled.

adrian-sturm avatar Apr 28 '23 11:04 adrian-sturm

Running into this too.

Should the "Disable Auto-Sync" button should be disabled/removed in situations where "self-heal" will simply revert? It's very confusing.

ScubaDrew avatar Aug 10 '23 17:08 ScubaDrew

Also check if you have an ApplicatoinSet that manages your Applications. In this case all changes to Application will be instantly undone, no matter what they were made with (UI/argocd cli/CRD)

v-avdeev avatar Aug 14 '23 08:08 v-avdeev

Also check if you have an ApplicatoinSet that manages your Applications. In this case all changes to Application will be instantly undone, no matter what they were made with (UI/argocd cli/CRD)

I also ran into this issue, which is disconcerting when trying to temporarily adjust settings, perform manual tests, rollbacks, or whatever else. Argo's UI seems to allow disabling regular apps, but when using an ApplicationSet (in my case, to generate ephemeral preview environments based on PRs) I'm unable to turn off the auto sync.

I'm not sure how to recommend a resolution, but this should certainly be addressed in some fashion. I think it's important to be able to disable sync, healing, etc on the apps created by an AppSet.

whitelancer avatar Aug 22 '23 14:08 whitelancer

Is there any movement on this?

illegalnumbers avatar Sep 22 '23 17:09 illegalnumbers

@illegalnumbers yes, this will allow folks to exclude fields from ApplicationSet's regular updates: https://github.com/argoproj/argo-cd/pull/14743

crenshaw-dev avatar Sep 22 '23 17:09 crenshaw-dev

I'm running into the same problem. Not using app of apps, literally just kubectl apply -f app.yaml

originally, I had automated filled in. But then I changed it to automated: {} and auto-sync is still reported as being enabled. Both from the CLI and UI.

Sync Policy:        Automated

I feel like the solution here is a simple one. Add an enabled field, then this becomes just a boolean value. It's easier to reason about for both the user and the code behind the scenes.

ghostsquad avatar Oct 21 '23 00:10 ghostsquad

I actually found out that setting this field to the null equivalent disables auto sync

  # Sync policy
  syncPolicy:
    automated:
image

ghostsquad avatar Oct 21 '23 00:10 ghostsquad

seems like it'll sync back to "enable" using all method

b8kings0ga avatar Dec 25 '23 07:12 b8kings0ga

syncPolicy: null

VesperDev avatar Jan 10 '24 22:01 VesperDev

In my case, I found a solution.

Environment

  • Amazon EKS v1.26
  • ArgoCD v2.9.5 (Installed by helm install command)

Solutions

Disable autosync in application spec:

# application resource spec
syncPolicy: {}

Enable autosync in application spec:

# application resource spec
syncPolicy:
  automated:
    prune: false
    selfHeal: false

or also valid spec:

# application resource spec
syncPolicy:
  automated: {}

Warning: You must definitely set syncPolicy value to null {} in order to disable auto-sync.

# application resource spec
- syncPolicy:
-   automated: {}
+ syncPolicy: {}

Reference

Automated sync policy

younsl avatar Mar 06 '24 09:03 younsl

We did this:

apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
spec:
  ignoreApplicationDifferences:
    - jsonPointers:
        - /spec/syncPolicy

From: https://argo-cd.readthedocs.io/en/stable/operator-manual/applicationset/Controlling-Resource-Modification/#allow-temporarily-toggling-auto-sync

And that worked!

hawkesn avatar Aug 12 '24 18:08 hawkesn

Experimentation:

  1. Auto-sync is ON.
syncPolicy:
  automated: {}
  1. Auto-sync is OFF, but the YAML schema^1 validator doesn't like it:
syncPolicy:
  automated:
  1. Auto-sync is OFF, and the YAML schema^1 validator likes it:
syncPolicy:

thiagowfx avatar Aug 14 '24 10:08 thiagowfx