argoproj / argo-cd

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

ArgoCD not trimming labels #14637

Open michalschott opened 1 year ago

michalschott commented 1 year ago

Checklist:

Describe the bug

In my case ArgoCD uses argocd.argoproj.io/instance: $APP_NAME to track ownership. In case length of $APP_NAME exceeds 63 characters kubernetes refuses to create object.

I believe this should / could be trimmed on ArgoCD level. Currently the only way to bypass this is by trimming $APP_NAME outside of ArgoCD.

To Reproduce

Expected behavior

Screenshots

Version

2.4.28 (have not checked newer versions, might not be related)

Logs

sync error message:

one or more objects failed to apply, reason: Namespace "$APP_NAME" is invalid: metadata.labels: Invalid value: "$APP_NAME": must be no more than 63 characters,namespaces "$APP_NAME" not found (retried 5 times).
crenshaw-dev commented 1 year ago

As far as I can tell, we only truncate labels if you're using annotation+label tracking, not just label. https://github.com/argoproj/argo-cd/blob/master/util/argo/resource_tracking.go#L143-L163

I'm not sure which should be changed, the docs or the implementation. https://argo-cd.readthedocs.io/en/stable/user-guide/resource_tracking/#tracking-kubernetes-resources-by-label

I lean towards changing just the docs. Annotation-based tracking should generally be preferred anyway.

michalschott commented 1 year ago

@crenshaw-dev thanks for explanation, I'll give annotation tracking a go.

jannfis commented 1 year ago

Please also be sure to upgrade to a more recent version :)