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

App names with non-alphanumeric characters in position 63 break syncs due to invalid label name #18237

Closed
3 tasks done
RobinsonZ opened this issue May 15, 2024 · 2 comments · Fixed by #18256
Closed
3 tasks done
Labels
bug Something isn't working

Comments

@RobinsonZ
Copy link
Contributor

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

When using annotation+label tracking method, app names with more than 63 characters are truncated to 63 characters. If the 63rd character is a hyphen, then the label value is invalid and the sync fails with the following error:

Failed sync attempt to a3e64b7ba2ba8ddc3d5878bc6aa2e116d29e0a50: one or more objects failed to apply, reason: ConfigMap "test" is invalid: metadata.labels: Invalid value: "the-very-suspicious-name-with-precisely-sixty-three-characters-": a valid label must be an empty string or consist of alphanumeric characters, '-', '_' or '.', and must start and end with an alphanumeric character (e.g. 'MyValue', or 'my_value', or '12345', regex used for validation is '(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?') (retried 1 times).

I believe the issue is in this code:

if len(val) > LabelMaxLength {
val = val[:LabelMaxLength]
}

To Reproduce

  1. Set application.resourceTrackingMethod: annotation+label in argocd-cm
  2. Create an application with a name that has a hyphen as its 63rd character, e.g. the-very-suspicious-name-with-precisely-sixty-three-characters-with-hyphen, containing any resources
  3. Attempt to sync the app

Expected behavior

The application syncs normally.

Screenshots

image
image

Version

argocd: v2.10.5+335875d
  BuildDate: 2024-03-28T16:12:55Z
  GitCommit: 335875d13e018bed6e03873f4742582582964745
  GitTreeState: clean
  GoVersion: go1.21.8
  Compiler: gc
  Platform: linux/amd64
argocd-server: v2.11.0-rc2+24ef777
  BuildDate: 2024-04-15T19:43:50Z
  GitCommit: 24ef7775e79a6ec20b441544aacf8d9d727a676f
  GitTreeState: clean
  GoVersion: go1.21.9
  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

Logs

N/A

@jannfis
Copy link
Member

jannfis commented May 16, 2024

This seems to be a duplicate of #10110

@RobinsonZ
Copy link
Contributor Author

Thanks for the catch - see my comment on #18256.

todaywasawesome pushed a commit that referenced this issue May 22, 2024
…syncs (issue #18237) (#18256)

* Ensure truncated app label does not end in a special character

Signed-off-by: Zack Robinson <robinsoz@arcesium.com>

* Move regex to global variable and add out of bounds check

Signed-off-by: Zack Robinson <robinsoz@arcesium.com>

* Add test for out-of-bounds check

Signed-off-by: Zack Robinson <robinsoz@arcesium.com>

---------

Signed-off-by: Zack Robinson <robinsoz@arcesium.com>
gcp-cherry-pick-bot bot pushed a commit that referenced this issue May 28, 2024
…syncs (issue #18237) (#18256)

* Ensure truncated app label does not end in a special character

Signed-off-by: Zack Robinson <robinsoz@arcesium.com>

* Move regex to global variable and add out of bounds check

Signed-off-by: Zack Robinson <robinsoz@arcesium.com>

* Add test for out-of-bounds check

Signed-off-by: Zack Robinson <robinsoz@arcesium.com>

---------

Signed-off-by: Zack Robinson <robinsoz@arcesium.com>
pasha-codefresh pushed a commit that referenced this issue May 28, 2024
…syncs (issue #18237) (#18256) (#18439)

* Ensure truncated app label does not end in a special character



* Move regex to global variable and add out of bounds check



* Add test for out-of-bounds check



---------

Signed-off-by: Zack Robinson <robinsoz@arcesium.com>
Co-authored-by: Zack Robinson <zkislakrobinson@gmail.com>
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
2 participants