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

Invalid characters in labele instance-type #645

Closed
sasho4ek07 opened this issue May 22, 2024 · 1 comment · Fixed by #770
Closed

Invalid characters in labele instance-type #645

sasho4ek07 opened this issue May 22, 2024 · 1 comment · Fixed by #770
Labels
bug Something isn't working good first issue Good for newcomers pinned

Comments

@sasho4ek07
Copy link

TL;DR

When trying to initialize a node on a bare metal host with a Dell PowerEdge™ type, an error occurs when setting the label: "instance-type"

Expected behavior

Node initialization without error

Observed behavior

When trying to initialize a node on a bare metal host with a Dell PowerEdge™ type, an error occurs when setting the label "instance-type". Since it contains the symbol ™, which is unacceptable for labels.

Minimal working example

it is necessary to remove invalid characters when obtaining instance-type from server data

func getInstanceTypeOfRobotServer(bmServer *models.Server) string {
	if bmServer == nil {
		panic("getInstanceTypeOfRobotServer called with nil server")
	}
	return regexp.MustCompile(`[^a-zA-Z0-9_.-]+`).ReplaceAllString(strings.ReplaceAll(bmServer.Product, " ", "-"), "")
}

Log output

E0521 09:46:06.971841       1 node_controller.go:240] error syncing 'bm-test-cluster-md-1-2djh8-mzbtq': Node "bm-test-cluster-md-1-2djh8-mzbtq" is invalid: metadata.labels: Invalid value: "Dell-PowerEdge™-R660-DX293": 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])?'), requeuing

Additional information

No response

@sasho4ek07 sasho4ek07 added the bug Something isn't working label May 22, 2024
@apricote apricote added good first issue Good for newcomers pinned labels Jul 8, 2024
@apricote
Copy link
Member

apricote commented Jul 8, 2024

Your suggested code looks good. Do you want to open a PR yourself? I would like to see:

  • The change to getInstanceTypeOfRobotServer + a comment that explains the TM issue
  • An update to the TestInstances_InstanceMetadataRobotServer to demonstrate that it works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers pinned
Projects
None yet
2 participants