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).
Set application.resourceTrackingMethod: annotation+label in argocd-cm
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
Checklist:
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:
https://github.com/argoproj/argo-cd/blob/2b89d6c2220160a55dd71b1f2b57f4744decf210/util/argo/resource_tracking.go#L156-L158
To Reproduce
application.resourceTrackingMethod: annotation+label
inargocd-cm
the-very-suspicious-name-with-precisely-sixty-three-characters-with-hyphen
, containing any resourcesExpected behavior
The application syncs normally.
Screenshots
Version
Logs
N/A