openshift / openshift/installer
vsphere NetworkDeviceSpec: CRD schema incorrectly uses format: ipv6 for fields that should accept both IPv4 and IPv6
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 1.6k
- Forks
- 1.5k
- Avg merge
- 5d 5h
- Merged PRs (30d)
- 39
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: https://github.com/openshift/hive/pull/2851#discussion_r2914003066
- Reported by: @2uasimojo
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in pkg/types/vsphere/platform.go and inspect the kubebuilder validation markers on NetworkDeviceSpec.gateway, ipAddrs, and nameservers, then review how controller-gen v0.19.0 produces the CRD schema. Regenerate or inspect the affected CRD YAML and verify that valid IPv4 and IPv6 values, including the documented examples, are accepted.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- infrastructure
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 65/100