-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Description
Summary
The generated CRD schema for the vSphere NetworkDeviceSpec incorrectly applies format: ipv6 to the gateway, ipAddrs, and nameservers fields. This causes the CRD to reject valid IPv4 inputs (e.g., 192.168.1.1, 8.8.8.8) even though both IPv4 and IPv6 are intended and documented.
Details
The Go source (in pkg/types/vsphere/platform.go) specifies both +kubebuilder:validation:Format=ipv4 and +kubebuilder:validation:Format=ipv6 markers on these fields. However, controller-gen (v0.19.0) collapses these into a single format: ipv6 in the generated CRD YAML, dropping the IPv4 constraint.
Affected fields within NetworkDeviceSpec (under spec.platform.vsphere.infrastructure.hosts[].networkDevice):
gatewayipAddrsnameservers
Impact
Any consumer that vendors this repository and generates CRDs from these types will produce a CRD schema that rejects IPv4 addresses for these fields, despite the field descriptions and examples explicitly showing IPv4 usage.
Suggested Fix
One of the following:
- Remove the
formatconstraint from these fields so both IPv4 and IPv6 are accepted without format validation. - Replace the single
format: ipv6with apattern-based validation that explicitly allows both IPv4 and IPv6 (and CIDR) formats. - Adjust the kubebuilder markers so that controller-gen generates a schema that correctly handles both address families.
Backlinks
- Discovered via: HIVE-2391: vsphere zonal hive#2851 (comment)
- Reported by: @2uasimojo