argoproj / argo-cd

Declarative Continuous Deployment for Kubernetes
https://argo-cd.readthedocs.io
Apache License 2.0
17.89k stars 5.46k forks source link

Unable to disable auto-sync #3895

Open sadovnikov opened 4 years ago

sadovnikov commented 4 years ago

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

  syncPolicy:
    automated: {}
  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

jannfis commented 4 years ago

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

Did I miss something?

sadovnikov commented 4 years ago

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!

dorroddorrod commented 3 years ago

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 commented 3 years ago

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

cheddarwhizzy commented 3 years ago
kubectl -n <namespace> patch --type='merge' application <app-name> -p "{\"spec\":{\"syncPolicy\":null}}"
ThoughtHopper commented 3 years ago

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" }

alexmt commented 3 years ago

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

converge commented 2 years ago

is there any update about this bug?

tommyalatalo commented 1 year ago

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

jannfis commented 1 year ago

Re-opening this as people reporting issue again.

thiagolsfortunato commented 1 year ago

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
adrian-sturm commented 1 year ago

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 commented 1 year ago

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!

olastefaniak commented 1 year ago

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 :)

adrian-sturm commented 1 year ago

@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.

ScubaDrew commented 1 year ago

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.

v-avdeev commented 1 year ago

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)

whitelancer commented 1 year ago

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.

illegalnumbers commented 1 year ago

Is there any movement on this?

crenshaw-dev commented 1 year ago

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

ghostsquad commented 1 year ago

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 commented 1 year ago

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

  # Sync policy
  syncPolicy:
    automated:
image
b8kings0ga commented 10 months ago

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

VesperDev commented 10 months ago

syncPolicy: null

younsl commented 8 months ago

In my case, I found a solution.

Environment

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

hawkesn commented 3 months ago

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!

thiagowfx commented 3 months ago

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: