argoproj / argo-cd

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

deployments getting restarted without any change in git #7357

Closed vijay-dcrust closed 3 years ago

vijay-dcrust commented 3 years ago

Checklist:

Describe the bug A git change in one of micorservices triggers restart of all the microservices in the cluster. An argocd app corresponds to each microservice. I am using application-set-controller for these microservices which inturn is installed through app-of-apps pattern. The common part of microservices is a set of common templates and common values.yaml file. Each microservice has its own values.yaml files also in a microservice specific folder.

To Reproduce App-set-controller definition

--- 
apiVersion: argoproj.io/v1alpha1
kind: ApplicationSet
metadata:
  name: backend-applications-microservices
  namespace: argocd
spec:
  generators:
  - list:
      elements:
      - cluster: dev
        url: <url>
        values:
          service_name: "app-1"
          service_namespace: "backend-namespace-01"
      - cluster: dev
        url: <url>
        values:
          service_name: "app-2"
          service_namespace: "backend-namespace-01"
      - cluster: dev
        url: <url>
        values:
          service_name: "app-3"
          service_namespace: "backend-namespace-01"
  template:
    metadata:
      name: '{{cluster}}-backend-{{values.service_name}}'
    spec:
      project: my-project-01
      source:
        repoURL: <git_deploy_repo>
        targetRevision: master
        path: helm/{{values.service_name}}
        helm:
          releaseName: '{{values.service_name}}'
          valueFiles: 
            - ../base/values.yaml
            - values.{{cluster}}.yaml
            - .values.{{cluster}}.yaml
      destination:
        server: '{{url}}'
        namespace: '{{values.service_namespace}}'
      syncPolicy:
        automated:
          selfHeal: true
          prune: true
        syncOptions:
        - CreateNamespace=true
  syncPolicy:
    preserveResourcesOnDeletion: true        

Structure of mentioned above looks like this.

helm
├── app-1
│   ├── Chart.lock
│   ├── Chart.yaml
│   ├── charts
│   │   └── base-0.1.0.tgz
│   ├── config.dev.json
│   ├── config.stg.json
│   ├── output.dev.yaml
│   ├── output.stg.yaml
│   ├── templates
│   │   ├── NOTES.txt
│   │   ├── _helpers.tpl
│   │   ├── configmap.yaml
│   │   ├── base-import.yaml
│   │   └── tests
│   │       └── test-connection.yaml
│   ├── values.dev.yaml
│   └── values.stg.yaml
├── app-2
│   ├── Chart.lock
│   ├── Chart.yaml
│   ├── charts
│   │   └── base-0.1.0.tgz
│   ├── config.dev.json
│   ├── config.stg.json
│   ├── output.stg.yaml
│   ├── templates
│   │   ├── NOTES.txt
│   │   ├── _helpers.tpl
│   │   ├── configmap.yaml
│   │   ├── deployment.yaml
│   │   ├── hpa.yaml
│   │   ├── ingress.yaml
│   │   ├── service.yaml
│   │   ├── serviceaccount.yaml
│   │   └── tests
│   │       └── test-connection.yaml
│   ├── values.dev.yaml
│   └── values.stg.yaml
├── base
│   ├── Chart.yaml
│   ├── templates
│   │   └── service.yaml
|   |    |_____ deployment.yaml
│   └── values.yaml

Expected behavior

If i make a change in one of the apps lets say i change any value in app1/values.yaml, argocd should start only app-1 to make it effective but not app-2.

Version

(base) $ argocd version
argocd: v2.0.4+0842d44.dirty
  BuildDate: 2021-06-23T07:11:51Z
  GitCommit: 0842d448107eb1397b251e63ec4d4bc1b4efdd6e
  GitTreeState: dirty
  GoVersion: go1.16.5
  Compiler: gc
  Platform: darwin/amd64
argocd-server: v2.0.4+0842d44
vijay-dcrust commented 3 years ago

This was happening due to a timestamp being passed as env variable to the deployments and since it is a dynamic value, it was causing the restart on sync randomly.

Closing the issue.