🐛 Fix issues for IPv6 support#1420
Conversation
31723c5 to
e4c472e
Compare
bryanv
left a comment
There was a problem hiding this comment.
I kind of infer that the unit tests were AI generated? Some of them look to duplicate what's already there, kind of test the same thing multiple times, and could be combined.
e4c472e to
4100030
Compare
2cc4a3f to
c05023f
Compare
Since, this bug came on IPv6 only setup, I tried to include all the possible combinations. |
The PR fixes 3 issues and adds comprehensive tests for IPv6 support.
What does this PR do, and why is it needed?
Issue1: Fix Critical Bug: IPv6-Only GOSC Customization
When only IPv6 is configured (no IPv4 addresses, no DHCP4), the adapter.Ip field remains nil, causing vSphere API to reject the customization spec.
Cause
The error occurs when customizing a VM with IPv6-only network configuration (no IPv4). The vSphere API requires the ip field in CustomizationIPSettings to be present, even when using IPv6.
Error Message
Required property ip is missing from data object of type CustomizationIPSettings
while parsing serialized DataObject of type vim.vm.customization.IPSettings
Error Flow
VM customization is triggered via doCustomize() in bootstrap.go:353
Customize() is called on the VM object (resources/vm.go:225)
vSphere API receives the customization spec with NicSettingMap
For the second adapter (IPv6-only), the spec has:
{
"macAddress": "00:50:56:96:8f:c8",
"adapter": {
"ip": null, // ❌ This is the problem
"ipV6Spec": {
"ip": [{"ipAddress": "2001:db8::100", "subnetMask": 64}],
"gateway": ["2001:db8::1"]
}
}
}
vSphere API rejects it because ip field is required
File: pkg/providers/vsphere/network/gosc.go:22-49
Fix Required:
After the IPv4 switch statement (after line 49), check if adapter.Ip is still nil and IPv6 is configured. If so, set adapter.Ip to:
&vimtypes.CustomizationDhcpIpGenerator{} (fallback - allows IPv4 DHCP but won't fail if IPv4 unavailable)
Issue2: Trivial: Update Outdated Comment
Current Code:
File: pkg/providers/vsphere/network/network.go:206-210
if interfaceSpec.DHCP6 {
// We don't really support IPv6 yet so this is only enabled when specified in
// the interface spec.
result.DHCP6 = true
}
Issue3: Handle IPv6-Only Scenarios in NetOP
File: pkg/providers/vsphere/network/network.go:461-475
Current Logic
When IPAssignmentMode == DHCP, sets DHCP4 = true regardless of available IP families
When IPAssignmentMode == StaticPool, processes all IPConfigs (both IPv4 and IPv6)
Fix
DHCP flag on the NetworkInterface indicates that dhcp4 and dhcp6 are enabled.
Add Comprehensive Tests
IPv6-only from NetOP (no IPv4 addresses)
IPv6-only GOSC customization (critical bug fix)
DHCP mode with IPv6 addresses
User-specified IPv6 addresses with NetOP-provided IPv4
User-specified IPv6 addresses only
IPv6 gateway handling (from NetOP, from user spec, "None" value)
Dual-stack with different gateways for IPv4 and IPv6
c05023f to
f408a1f
Compare
Minimum allowed line rate is |
aruneshpa
left a comment
There was a problem hiding this comment.
LGTM @hpannem ! Thanks for this contribution.
One nit: can you sanitize the PR description (and the commit message) to remove the superfluous information? Currently the PR description contains a lot of generated things that we don't need over there. Don't get me wrong, more context is helpful, but I think we can trim it down a bunch from its current form.
Thanks again!
The PR fixes 3 issues and adds comprehensive tests for IPv6 support.
What does this PR do, and why is it needed?
Issue1: Fix Critical Bug: IPv6-Only GOSC Customization
When only IPv6 is configured (no IPv4 addresses, no DHCP4), the
adapter.Ipfield remainsnil, causing vSphere API to reject the customization spec.Cause
The error occurs when customizing a VM with IPv6-only network configuration (no IPv4). The vSphere API requires the
ipfield inCustomizationIPSettingsto be present, even when using IPv6.Error Message
Error Flow
doCustomize()inbootstrap.go:353Customize()is called on the VM object (resources/vm.go:225)NicSettingMap{ "macAddress": "00:50:56:96:8f:c8", "adapter": { "ip": null, // ❌ This is the problem "ipV6Spec": { "ip": [{"ipAddress": "2001:db8::100", "subnetMask": 64}], "gateway": ["2001:db8::1"] } } }ipfield is requiredFile: `pkg/providers/vsphere/network/gosc.go:
Fix Required:
Set adapter.Ip to DisableIpv4 option to satisfy vSphere requirement.
Issue2: Trivial: Update Outdated Comment
Current Code:
File:
pkg/providers/vsphere/network/network.go:206-210Removed the following comment since we support IPv6, dualstack.
Issue3: Handle DHCP Scenarios with NetOP
File:
pkg/providers/vsphere/network/network.goCurrent Logic
IPAssignmentMode == DHCP, setsDHCP4 = trueregardless of available IP familiesFix
DHCP flag on the NetworkInterface indicates that dhcp4 and dhcp6 are enabled.
Add Comprehensive Tests
Which issue(s) is/are addressed by this PR? (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)format, will close the issue(s) when PR gets merged):Fixes #
Are there any special notes for your reviewer:
NONE
Please add a release note if necessary:
NONE