Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trimming tracking labels can lead to invalid Kubernetes labels #17809

Closed
3 tasks done
fdpeiter opened this issue Apr 11, 2024 · 2 comments
Closed
3 tasks done

Trimming tracking labels can lead to invalid Kubernetes labels #17809

fdpeiter opened this issue Apr 11, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@fdpeiter
Copy link

Checklist:

  • I've searched in the docs and FAQ for my answer: https://bit.ly/argocd-faq.
  • I've included steps to reproduce the bug.
  • I've pasted the output of argocd version.

Describe the bug

ArgoCD trims the labels for tracking ids automatically. When using namespaces, particularly, this can lead to resources being trimmed and ending with _, . or -. This generates an invalid label and the resource can't be created in Kubernetes.

This issue is particularly more visible when using namespaces, as the resulting label, for example, argocd.argoproj.io/instance, is generated with ArgoCDNamespace_ArgoCDResourceName.

To Reproduce

Generate any resource with the 63rd character being an invalid one:

  • ArgoCD Namespace: custom-cluster-ap-northeast2-production
  • ArgoCD Resource Name: my-custom-resource-has-a-long-name
    Resulting Kubernetes label:
    argocd.argoproj.io/instance="custom-cluster-ap-northeast2-production_my-custom-resource-has-"

This generates an invalid Kuberentes manifest.

Expected behavior

Add a validation in the trimming function to avoid generating invalid resources. Like trimming the name until we find the first to last valid character.

Screenshots

Version

argocd: v2.10.6+d504d2b.dirty
  BuildDate: 2024-04-05T03:31:58Z
  GitCommit: d504d2b1d92f0cf831a124a5fd1a96ee29fa7679
  GitTreeState: dirty
  GoVersion: go1.22.2
  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/arm64
  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

Logs

Paste any relevant application logs here.
@jannfis
Copy link
Member

jannfis commented Apr 12, 2024

Dupe of #10110

@fdpeiter
Copy link
Author

Indeed it is. Thanks for pointing out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants