kubernetes-sigs / cluster-api-provider-vsphere

Apache License 2.0
369 stars 294 forks source link

Cluster creation fails when using invalid label values for ESXi host info #1674

Closed srm09 closed 1 year ago

srm09 commented 1 year ago

/kind bug

What steps did you take and what happened:

  1. In the vCenter instance, configure the ESXi hosts to have an IPv6 address as the primary address.
  2. Create a cluster with 1 control plane and 1 worker nodes
  3. Cluster creation fails with the following errors in the logs:
    E1031 17:21:43.140137       1 vspheremachine_controller.go:331] capv-controller-manager/vspheremachine-controller "msg"="failed to patch machine with host info label" "error"="Machine.cluster.x-k8s.io \"mgmt-vc-control-plane-27f4d\" is invalid: metadata.labels: Invalid value: \"2620:124:6020:c003:0:69ff:fe2b:3763\": 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])?')"  "machine "="mgmt-vc-control-plane-27f4d"
    E1031 17:21:43.140980       1 controller.go:317] controller/vspheremachine "msg"="Reconciler error" "error"="Machine.cluster.x-k8s.io \"mgmt-vc-control-plane-27f4d\" is invalid: metadata.labels: Invalid value: \"2620:124:6020:c003:0:69ff:fe2b:3763\": 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])?')" "name"="mgmt-vc-control-plane-q5kzq" "namespace"="default" "reconciler group"="infrastructure.cluster.x-k8s.io" "reconciler kind"="VSphereMachine"

What did you expect to happen: Cluster creation proceeds without any errors.

Anything else you would like to add: [Miscellaneous information that will assist in solving the issue.]

Environment:

/assign

srm09 commented 1 year ago

The main reason behind the failure is the restriction on the character set that can be used as valid label values. K8s docs around the table value syntax can be found here.

Based on the above documentation, these could also fail for a host with a DNS name greater than 63 characters.

srm09 commented 1 year ago

/retitle Cluster creation fails when using invalid label values for ESXi host info