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

failure with invalid label value #5364

Open
3 tasks done
strantalis opened this issue Jan 31, 2021 · 5 comments
Open
3 tasks done

failure with invalid label value #5364

strantalis opened this issue Jan 31, 2021 · 5 comments
Labels
wontfix This will not be worked on

Comments

@strantalis
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

When adding an invalid unquoted numeric label value argocd removes all other labels from the namespace.

To Reproduce

Initial Namespace

apiVersion: v1
kind: Namespace
metadata:
  name: label-test
  labels:
    label-1: "12345"

Now add a label-2 unquoted. Argocd will show label-1 being removed.

apiVersion: v1
kind: Namespace
metadata:
  name: label-test
  labels:
    label-1: "12345"
    label-2: 12345

Expected behavior

With this being an invalid label value I would expect argocd to produce an error.

Version

$ argocd version
argocd: v1.7.6+b04c25e
  BuildDate: 2020-09-19T00:50:44Z
  GitCommit: b04c25eca8f1660359e325acd4be5338719e59a0
  GitTreeState: clean
  GoVersion: go1.14.1
  Compiler: gc
  Platform: linux/amd64
@strantalis strantalis added the bug Something isn't working label Jan 31, 2021
@jessesuen
Copy link
Member

This is not Argo CD doing this, it is kubernetes. Kubernetes drops the entire labels/annotations if there is one invalid value applied.

@jessesuen jessesuen added wontfix This will not be worked on and removed bug Something isn't working labels Feb 1, 2021
@strantalis
Copy link
Author

@jessesuen So I probably don't understand everything fully but I thought argocd validates all manifest before being applied?

When do I kubectl apply --dry-run the namespace comes back invalid.

❯ kubectl apply --server-side=true --dry-run=server -f namespace.yaml
error: unable to decode "namespace.yaml": resource.metadataOnlyObject.ObjectMeta: v1.ObjectMeta.Labels: ReadString: expects " or n, but found 1, error found in #10 byte of ...|label-2":12345},"nam|..., bigger context ...|metadata":{"labels":{"label-1":"12345","label-2":12345},"name":"label-test"}}|...
kubectl apply --dry-run=client -f namespace.yaml
error: unable to decode "namespace.yaml": resource.metadataOnlyObject.ObjectMeta: v1.ObjectMeta.Labels: ReadString: expects " or n, but found 1, error found in #10 byte of ...|label-2":12345},"nam|..., bigger context ...|metadata":{"labels":{"label-1":"12345","label-2":12345},"name":"label-test"}}|...

@alexmt
Copy link
Collaborator

alexmt commented Feb 2, 2021

The 1.8 has an improvement #1787 . Argo CD used to drop unknown fields - now such fields stay untouched. @strantalis can you please check if upgrade resolves issue?

@strantalis
Copy link
Author

I tried upgrading to 1.8.3 but it still didn't seem to change anything. This is the namespace definition in git below and some screenshots of live, diff and desired.

apiVersion: v1
kind: Namespace
metadata:
  name: label-test
  labels:
    label-1: "12345"
    label-2: 12345

Live

Diff

Desired

@strantalis
Copy link
Author

@alexmt One thing I noticed is argocd/kube does block a bad label with spaces on sync so not sure whats going on with the integer label value. Seems to be something happening before the sync phase. Maybe when it does the diff?

apiVersion: v1
kind: Namespace
metadata:
  labels:
    argocd.argoproj.io/instance: label-test
    label-1: '12345'
    spaces: This is invalid
  name: label-test
Namespace "label-test" is invalid: metadata.labels: Invalid value: "This is invalid": 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])?')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

3 participants