argoproj / argo-cd

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

Rename and change of YAML file leads to Sync failure (without kustomize) #17392

Open NiroDeveloper opened 6 months ago

NiroDeveloper commented 6 months ago

Checklist:

Describe the bug

Rename and change a YAML file in the same commit leads to a sync failure. In this example ArgoCD tries to add the new YAML variables without removing the old ones, that leads to two multiple probe handlers. (Remove exec liveness probe and add http probe) Problem only occures WITHOUT kustomize.

To Reproduce

  1. Create an pod without kustomize and let it deploy via argocd
    apiVersion: v1
    kind: Pod
    metadata:
    labels:
    test: liveness
    name: liveness-test
    spec:
    containers:
    - name: liveness
    image: registry.k8s.io/busybox
    args:
    - /bin/sh
    - -c
    - touch /tmp/healthy; sleep 30; rm -f /tmp/healthy; sleep 600
    livenessProbe:
      exec:
        command:
        - cat
        - /tmp/healthy
      initialDelaySeconds: 5
      periodSeconds: 5
  2. In the same commit rename the file and change the livenessProbe
    apiVersion: v1
    kind: Pod
    metadata:
    labels:
    test: liveness
    name: liveness-test
    spec:
    containers:
    - name: liveness
    image: registry.k8s.io/busybox
    args:
    - /bin/sh
    - -c
    - touch /tmp/healthy; sleep 30; rm -f /tmp/healthy; sleep 600
    livenessProbe:
      httpGet:
        path: /healthz
        port: 8080
        httpHeaders:
        - name: Custom-Header
          value: Awesome
      initialDelaySeconds: 5
      periodSeconds: 5
  3. See ArgoCD OutOfSync Error (Not from this example, but same behavior)
    one or more objects failed to apply, reason: error when patching "/dev/shm/2076440606": Deployment.apps "pod-name" is invalid: [spec.template.spec.containers[2].livenessProbe.tcpSocket: Forbidden: may not specify more than 1 handler type, spec.template.spec.containers[2].startupProbe.tcpSocket: Forbidden: may not specify more than 1 handler type]. Retrying attempt #4 at 2:27PM.
  4. Fix this by Sync-Button and enable prune, so it will build a completely fresh instance

Expected behavior

ArgoCD should remove the attributes removed from the manifest, so the Sync runs without failure.

Screenshots

image

ArgoCD only adds the new attributes and does not remove the old probe. image

Version

{
    "Version": "v2.10.1+a79e0ea",
    "BuildDate": "2024-02-14T17:37:43Z",
    "GitCommit": "a79e0eaca415461dc36615470cecc25d6d38cefb",
    "GitTreeState": "clean",
    "GoVersion": "go1.21.3",
    "Compiler": "gc",
    "Platform": "linux/amd64",
    "KustomizeVersion": "v5.2.1 2023-10-19T20:13:51Z",
    "HelmVersion": "v3.14.0+g3fc9f4b",
    "KubectlVersion": "v0.26.11",
    "JsonnetVersion": "v0.20.0"
}
yasn77 commented 5 months ago

I am not sure if it's related, but I've been hit with a similar problem (using Kustomize). After renaming and updating the same file, i get the following error:

Failed to load target state: failed to generate manifest for source 1 of 1: rpc error: code = Unknown desc = Manifest generation error (cached): `kustomize build <path to cached source>/metrics/datadog-operator/shared` failed exit status 1: Error: accumulating resources: accumulation err='accumulating resources from 'externalparams.yaml': evalsymlink failure on '<path to cached source>/metrics/datadog-operator/shared/externalparams.yaml' : lstat <path to cached source>/metrics/datadog-operator/shared/externalparams.yaml: no such file or directory': must build at directory: not a valid directory: evalsymlink failure on '<path to cached source>/metrics/datadog-operator/shared/externalparams.yaml' : lstat <path to cached source>/metrics/datadog-operator/shared/externalparams.yaml: no such file or directory

The file was renamed from externalparams.yaml to externalparams.yaml

I tried refreshing the app and repo (hard refresh) to no avail.

If it's not related to this issue, I can open a new issue.