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

When ServerSideDiff is enabled, modifying a service or container port number results in "duplicate" error. Diff cannot complete. #17717

Open avo-sepp opened 7 months ago

avo-sepp commented 7 months ago

Checklist:

Describe the bug

When ServerSideDiff BETA is enabled, changing the pod or service port number without changing the name of the port results in an error stating duplicate "port name". The expected behavior would be that the port is overwritten by apply.

To Reproduce

Deploy a pod and service with ArgoCD, enable ServerSideDiff beta for ArgoCD. Then try and change just the port number for the service + container without changing the name of the port/service.

Expected behavior

ArgoCD should rewrite the Pod/Container and Service with the updated pod number.

Version

argocd: v2.10.4+f5d63a5.dirty BuildDate: 2024-03-18T09:28:41Z GitCommit: f5d63a5c77d2e804e51ef94bee3db441e0789d00 GitTreeState: dirty GoVersion: go1.22.1 Compiler: gc Platform: darwin/arm64 argocd-server: v2.10.5+335875d BuildDate: 2024-03-28T15:02:45Z GitCommit: 335875d13e018bed6e03873f4742582582964745 GitTreeState: clean GoVersion: go1.21.3 Compiler: gc Platform: linux/amd64 Kustomize Version: v5.2.1 2023-10-19T20:13:51Z Helm Version: v3.14.3+gf03cc04 Kubectl Version: v0.26.11 Jsonnet Version: v0.20.0

Screenshots Screenshot 2024-04-03 at 11 00 05

Logs

Failed to compare desired state to live state: failed to calculate diff: error calculating server side diff: serverSideDiff error: error running server side apply in dryrun mode for resource Deployment/workerservice-prod-uc-http-service: Deployment.apps "workerservice-prod-uc-http-service" is invalid: spec.template.spec.containers[0].ports[1].name: Duplicate value: "http"
avo-sepp commented 7 months ago

Just for FYI, Force and Replace did not fix the issue in ArgoCD. I had to manually delete the service in Kubernetes. Not a possibility for production systems.

klemmster commented 5 months ago

This also happens when changing the port name, not the number

zswanson commented 1 month ago

Verified having this issue. Moreover, deleting the 'conflicting' object is only a 1 time fix. It continues to happen on every sync.

BarAshkenazi commented 1 month ago

Confirming that I was able to reproduce this issue as well on version 2.12.3, a fix will be beneficial

NiklasRosenstein commented 3 weeks ago

Same here, I was about to update Immich on my server, they changed the port number. Instead of replacing the ports entirely, the new item is appended ...? I don't see how this would be intentional semantics.

image

image

image

I also have the same issue for a Deployment's container's ports list (also in Immich, same port number change).

andrii-korotkov-verkada commented 20 hours ago

ArgoCD versions 2.10 and below have reached EOL. Can you upgrade and tell us if the issue is still present, please?

BarAshkenazi commented 1 hour ago

@andrii-korotkov-verkada I was able to reproduce this issue as well on version 2.12.3