hcloud-cloud-controller-manager
hcloud-cloud-controller-manager copied to clipboard
Invalid characters in labele instance-type
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