cluster-api-provider-vsphere
cluster-api-provider-vsphere copied to clipboard
waitForIPv{4,6} is not set correctly when ipAddrs is set
/kind bug
What steps did you take and what happened:
We found what appears to be a bug in the code (and test) here: https://github.com/kubernetes-sigs/cluster-api-provider-vsphere/blob/main/pkg/util/machines.go#L154-L164
We were updating the test in a PR we're making, and discovered that the above code incorrectly
checks to see if the supplied IP parses successfully. The admission webhook requires the IPs are in CIDR format [1]. The CIDR based IPs supplied to this function will never parse using net.ParseIP(). It seems the code should be using net.ParseCIDR() instead.
This means that the waitForIPv4 and waitForIPv6 flags are never set to true when supplying valid CIDR based IPs. It appears that the waitForIPv{4,6} is used so that cloud-init does not process network information before the DHCP server has
assigned IPs. When supplying IPs, it may not be necessary to wait.
It seems this has been this way for quite some time, and 'fixing' it to what appears to be what was intended may have unknown, undesirable effects.
[1] - https://github.com/kubernetes-sigs/cluster-api-provider-vsphere/blob/main/apis/v1beta1/vspheremachine_webhook.go#L60-L66
What did you expect to happen:
I expect the waitForIPv4 flag and the waitForIPv6 to be set to true when supplying the IPs in the required CIDR format.
Anything else you would like to add: [Miscellaneous information that will assist in solving the issue.]
Environment:
- Cluster-api-provider-vsphere version: main branch
- Kubernetes version: (use
kubectl version): N/A - OS (e.g. from
/etc/os-release): N/A
cc @adobley @christianang @flawedmatrix