argoproj / argo-cd

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

--dry-run and --local mutates live resources #3856

Open igaskin opened 4 years ago

igaskin commented 4 years ago

Describe the bug

the --dry-run flag actual modifies the desired state of resources in an application

To Reproduce

Expected behavior

When running sync with --dry-run it should not make any modifications to applications or live kubernetes resources

Screenshots

If applicable, add screenshots to help explain your problem.

Version

argocd version
argocd: v1.6.0+a886241.dirty
  BuildDate: 2020-06-26T06:08:39Z
  GitCommit: a886241ef2db90ae1c0d76c50d603a9de9246ed0
  GitTreeState: dirty
  GoVersion: go1.14.4
  Compiler: gc
  Platform: linux/amd64
argocd-server: v99.99.99+unknown
  BuildDate: 1970-01-01T00:00:00Z
  GitCommit: 
  GitTreeState: 
  GoVersion: go1.14.1
  Compiler: gc
  Platform: linux/amd64
  Ksonnet Version: v0.13.1
  Kustomize Version: {Version:kustomize/v3.6.1 GitCommit:c97fa946d576eb6ed559f17f2ac43b3b5a8d5dbd BuildDate:2020-05-27T20:47:35Z GoOs:linux GoArch:amd64}
  Helm Version: version.BuildInfo{Version:"v3.2.0", GitCommit:"e11b7ce3b12db2941e90399e874513fbd24bcb71", GitTreeState:"clean", GoVersion:"go1.13.10"}
  Kubectl Version: v1.14.0```

Logs

output of dry-run

 argocd app sync --dry-run --local . faa
INFO[0000] helm2 init --client-only --skip-refresh       dir=. execID=qecE5
INFO[0000] helm2 template . --name faa --namespace default --kube-version 1.18  dir=. execID=vGCsP
TIMESTAMP                  GROUP        KIND       NAMESPACE                  NAME               STATUS    HEALTH        HOOK  MESSAGE
2020-06-25T23:59:24-07:00   apps  Deployment         default   faa-appmesh-grafana               Synced   Healthy              
2020-06-25T23:59:24-07:00          ConfigMap         default  faa-appmesh-grafana-dashboards     Synced                        
2020-06-25T23:59:24-07:00          ConfigMap         default  faa-appmesh-grafana-datasources    Synced                        
2020-06-25T23:59:24-07:00          ConfigMap         default  faa-appmesh-grafana-ini          OutOfSync                       
2020-06-25T23:59:24-07:00          ConfigMap         default  faa-appmesh-grafana-providers      Synced                        
2020-06-25T23:59:24-07:00            Service         default   faa-appmesh-grafana               Synced   Healthy              
2020-06-25T23:59:24-07:00         ServiceAccount     default   faa-appmesh-grafana               Synced                        
2020-06-25T23:59:25-07:00            Service         default   faa-appmesh-grafana               Synced   Healthy              service/faa-appmesh-grafana configured (dry run)
2020-06-25T23:59:25-07:00   apps  Deployment         default   faa-appmesh-grafana               Synced   Healthy              deployment.apps/faa-appmesh-grafana configured (dry run)
2020-06-25T23:59:25-07:00          ConfigMap         default  faa-appmesh-grafana-ini          OutOfSync                       configmap/faa-appmesh-grafana-ini configured (dry run)
2020-06-25T23:59:25-07:00          ConfigMap         default  faa-appmesh-grafana-datasources    Synced                        configmap/faa-appmesh-grafana-datasources configured (dry run)
2020-06-25T23:59:25-07:00          ConfigMap         default  faa-appmesh-grafana-providers      Synced                        configmap/faa-appmesh-grafana-providers configured (dry run)
2020-06-25T23:59:25-07:00          ConfigMap         default  faa-appmesh-grafana-dashboards     Synced                        configmap/faa-appmesh-grafana-dashboards configured (dry run)
2020-06-25T23:59:25-07:00         ServiceAccount     default   faa-appmesh-grafana               Synced                        serviceaccount/faa-appmesh-grafana configured (dry run)

Name:               faa
Project:            default
Server:             https://kubernetes.default.svc
Namespace:          default
URL:                http://127.0.0.1:8080/applications/faa
Repo:               https://github.com/igaskin/eks-charts
Target:             feat/VN-38191/argo-sandbox
Path:               stable/appmesh-grafana
SyncWindow:         Sync Allowed
Sync Policy:        <none>
Sync Status:        OutOfSync from feat/VN-38191/argo-sandbox
Health Status:      Healthy

Operation:          Sync
Sync Revision:      
Phase:              Succeeded
Start:              2020-06-25 23:59:24 -0700 PDT
Finished:           2020-06-25 23:59:25 -0700 PDT
Duration:           1s
Message:            successfully synced (no more tasks)

GROUP  KIND            NAMESPACE  NAME                             STATUS     HEALTH   HOOK  MESSAGE
       ConfigMap       default    faa-appmesh-grafana-ini          OutOfSync                 configmap/faa-appmesh-grafana-ini configured (dry run)
       ConfigMap       default    faa-appmesh-grafana-datasources  Synced                    configmap/faa-appmesh-grafana-datasources configured (dry run)
       ConfigMap       default    faa-appmesh-grafana-providers    Synced                    configmap/faa-appmesh-grafana-providers configured (dry run)
       ConfigMap       default    faa-appmesh-grafana-dashboards   Synced                    configmap/faa-appmesh-grafana-dashboards configured (dry run)
       ServiceAccount  default    faa-appmesh-grafana              Synced                    serviceaccount/faa-appmesh-grafana configured (dry run)
       Service         default    faa-appmesh-grafana              Synced     Healthy        service/faa-appmesh-grafana configured (dry run)
apps   Deployment      default    faa-appmesh-grafana              Synced     Healthy        deployment.apps/faa-appmesh-grafana configured (dry run)
WARN[0001] failed to close &{0x178acd0}: rpc error: code = Canceled desc = grpc: the client connection is closing 

controller logs

06:59:25  controller | INFO[2495] adding resource result, status: 'Synced', phase: 'Running', message: 'configmap/faa-appmesh-grafana-ini configured (dry run)'  application=faa kind=ConfigMap name=faa-appmesh-grafana-ini namespace=default phase=Sync syncId=00022-SCicg
darshanime commented 4 years ago

should be closed by https://github.com/argoproj/argo-cd/pull/3891

chihaiaalex commented 4 years ago

Hi. The issue still persists for me.

I have the following setup

argocd: v1.7.0+3d4d64e BuildDate: 2020-08-12T13:45:32Z GitCommit: 3d4d64e1b7ec1f7d1fa59d02d82960512dead84c GitTreeState: clean GoVersion: go1.14.1 Compiler: gc Platform: linux/amd64 argocd-server: v1.7.0+3d4d64e BuildDate: 2020-08-12T13:47:37Z GitCommit: 3d4d64e1b7ec1f7d1fa59d02d82960512dead84c GitTreeState: clean GoVersion: go1.14.1 Compiler: gc Platform: linux/amd64 Ksonnet Version: v0.13.1 Kustomize Version: {Version:kustomize/v3.6.1 GitCommit:c97fa946d576eb6ed559f17f2ac43b3b5a8d5dbd BuildDate:2020-05-27T20:47:35Z GoOs:linux GoArch:amd64} Helm Version: version.BuildInfo{Version:"v3.2.0", GitCommit:"e11b7ce3b12db2941e90399e874513fbd24bcb71", GitTreeState:"clean", GoVersion:"go1.13.10"} Kubectl Version: v1.17.8

project: prod-config-mgmt
source:
  repoURL: 'ssh://git@host:7999/dop/kubernetes-prod-config.git'
  path: clusters/prod-zone01/
  targetRevision: master
destination:
  server: 'https://<ip>:6443'
  namespace: default
syncPolicy:
  automated:
    selfHeal: true

Steps to reproduce:

  1. Create application.
  2. Checkout configuration repository and make a change locally without pushing it.
  3. Run a dry run: argocd app sync prod-config-mgmt --dry-run --local clusters/prod-zone01 > output.yaml (Note that this command exists with an warning for me:

WARN[0004] failed to close &{0x18a5160}: rpc error: code = Canceled desc = grpc: the client connection is closing

  1. Check the ArgoCD interface - application is Synced
  2. Press refresh button
  3. Application is OutOfSync - the changes that I made locally with dry-run affected the live state.

Expected:

The dry-run should not affect the application state at all.

dsuievalov commented 3 years ago

Hello, the same issue exist on version v1.7.6+b04c25e.

sidewinder12s commented 3 years ago

Looks like this is still an issue in version v2.1.4+d5c6608

When using both --local and --dry-run together and when only running with --dry-run. Which makes me think --dry-run doesn't actually work at all?

servo1x commented 2 years ago

Still have this issue with 2.2.5.

Brightside56 commented 2 years ago

Still have this issue with 2.3.4