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

K8SSAND-1523 ⁃ Label values are not validated when created #335

Closed
burmanm opened this issue May 22, 2022 · 1 comment · Fixed by #339
Closed

K8SSAND-1523 ⁃ Label values are not validated when created #335

burmanm opened this issue May 22, 2022 · 1 comment · Fixed by #339
Assignees
Labels
bug Something isn't working zh:Done

Comments

@burmanm
Copy link
Contributor

burmanm commented May 22, 2022

What happened?
I was migrating an existing cluster to the cass-operator and it had a Cluster name of Test Cluster. This caused cass-operator to try to label some resources with incorrect labels:

  Warning  ReconcileFailed  72s (x8 over 83s)  cass-operator  Service "testcluster-seed-service" is invalid: [metadata.labels: Invalid value: "cassandra-Test Cluster": 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])?'), metadata.labels: Invalid value: "Test Cluster": 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])?'), spec.selector: Invalid value: "Test Cluster": 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])?')]

We validate clusterName in multiple places and strip incorrect characters. We should be doing the same in these labels also (and ensure that the queries still work).

Did you expect to see something different?

How to reproduce it (as minimally and precisely as possible):
Create CassDc with Cluster: Test Cluster.

Environment

  • Cass Operator version:

    Insert image tag or Git SHA here

    * Kubernetes version information:

    kubectl version

    * Kubernetes cluster kind:
insert how you created your cluster: kops, bootkube, etc.
  • Manifests:
insert manifests relevant to the issue
  • Cass Operator Logs:
insert Cass Operator logs relevant to the issue here

Anything else we need to know?:

┆Issue is synchronized with this Jira Task by Unito
┆friendlyId: K8SSAND-1523
┆priority: Medium

@burmanm burmanm added the bug Something isn't working label May 22, 2022
@sync-by-unito sync-by-unito bot changed the title Label values are not validated when created K8SSAND-1523 ⁃ Label values are not validated when created May 22, 2022
@burmanm
Copy link
Contributor Author

burmanm commented May 30, 2022

A good way would be to use the given regexp (regex used for validation is '(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?')) and just take the input from Cluster field and remove all chars that do not conform to this regexp.

That way all existing clusters would be unimpacted.

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

Successfully merging a pull request may close this issue.

3 participants