Skip to content

🐛 Fix issues for IPv6 support#1420

Merged
aruneshpa merged 1 commit intovmware-tanzu:mainfrom
hpannem:topic/hpannem/ipv6fixes
Feb 3, 2026
Merged

🐛 Fix issues for IPv6 support#1420
aruneshpa merged 1 commit intovmware-tanzu:mainfrom
hpannem:topic/hpannem/ipv6fixes

Conversation

@hpannem
Copy link
Contributor

@hpannem hpannem commented Jan 14, 2026

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

  1. VM customization is triggered via doCustomize() in bootstrap.go:353
  2. Customize() is called on the VM object (resources/vm.go:225)
  3. vSphere API receives the customization spec with NicSettingMap
  4. 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"]
        }
      }
    }
  5. vSphere API rejects it because ip field is required

File: `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-210

Removed the following comment since we support IPv6, dualstack.

// We don't really support IPv6 yet so this is only enabled when specified in
// the interface spec.

Issue3: Handle DHCP Scenarios with NetOP
File: pkg/providers/vsphere/network/network.go

Current Logic

  • When IPAssignmentMode == DHCP, sets DHCP4 = true regardless of available IP families

Fix
DHCP flag on the NetworkInterface indicates that dhcp4 and dhcp6 are enabled.

Add Comprehensive Tests

  1. IPv6-only from NetOP (no IPv4 addresses)
  2. IPv6-only GOSC customization (critical bug fix)
  3. DHCP mode with IPv6 addresses
  4. User-specified IPv6 addresses with NetOP-provided IPv4
  5. User-specified IPv6 addresses only
  6. IPv6 gateway handling (from NetOP, from user spec, "None" value)
  7. Dual-stack with different gateways for IPv4 and IPv6

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

@github-actions github-actions bot added the size/XXL Denotes a PR that changes 1000+ lines. label Jan 14, 2026
@hpannem hpannem changed the title ipv6 fixes 🐛 Fix issues for IPv6 support Jan 14, 2026
@hpannem hpannem force-pushed the topic/hpannem/ipv6fixes branch 2 times, most recently from 31723c5 to e4c472e Compare January 15, 2026 20:56
Copy link
Contributor

@bryanv bryanv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@hpannem hpannem force-pushed the topic/hpannem/ipv6fixes branch from e4c472e to 4100030 Compare January 24, 2026 04:29
@github-actions github-actions bot added size/XL Denotes a PR that changes 500-999 lines. and removed size/XXL Denotes a PR that changes 1000+ lines. labels Jan 24, 2026
@hpannem hpannem force-pushed the topic/hpannem/ipv6fixes branch 2 times, most recently from 2cc4a3f to c05023f Compare January 24, 2026 04:38
@hpannem
Copy link
Contributor Author

hpannem commented Jan 24, 2026

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.

Since, this bug came on IPv6 only setup, I tried to include all the possible combinations.
There are a lot of combinations using these options [static, dhcp, ipv4, ipv6, dual stack, multiple IPs] for netplan or GOSC,
and overall level at the network_test.
Besides these, there can be user inputs from virtualmachine networks CR.
I wanted to cover all these paths. Yes, there may be duplicates.
Anyways, I tried to de-deduplicate to a set of minimal tests that covers the all the paths at different layers. Please take a look.

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
@hpannem hpannem closed this Jan 24, 2026
@hpannem hpannem force-pushed the topic/hpannem/ipv6fixes branch from c05023f to f408a1f Compare January 24, 2026 04:53
@hpannem hpannem reopened this Jan 24, 2026
@hpannem hpannem requested a review from bryanv January 26, 2026 19:15
@github-actions
Copy link

Code Coverage

Package Line Rate Health
github.com/vmware-tanzu/vm-operator/controllers/contentlibrary/clustercontentlibraryitem 67%
github.com/vmware-tanzu/vm-operator/controllers/contentlibrary/contentlibraryitem 67%
github.com/vmware-tanzu/vm-operator/controllers/contentlibrary/utils 46%
github.com/vmware-tanzu/vm-operator/controllers/infra/capability/configmap 92%
github.com/vmware-tanzu/vm-operator/controllers/infra/capability/crd 100%
github.com/vmware-tanzu/vm-operator/controllers/infra/configmap 75%
github.com/vmware-tanzu/vm-operator/controllers/infra/node 77%
github.com/vmware-tanzu/vm-operator/controllers/infra/secret 76%
github.com/vmware-tanzu/vm-operator/controllers/infra/validatingwebhookconfiguration 87%
github.com/vmware-tanzu/vm-operator/controllers/infra/zone 73%
github.com/vmware-tanzu/vm-operator/controllers/storage/storageclass 96%
github.com/vmware-tanzu/vm-operator/controllers/storage/storagepolicy 96%
github.com/vmware-tanzu/vm-operator/controllers/storage/storagepolicyquota 91%
github.com/vmware-tanzu/vm-operator/controllers/util/encoding 73%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachine/storagepolicyusage 96%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachine/virtualmachine 68%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachine/volume 86%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachine/volumebatch 86%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachineclass 73%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachinegroup 90%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachinegrouppublishrequest 88%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachineimagecache 86%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachinepublishrequest 83%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachinereplicaset 67%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachineservice 82%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachineservice/providers 92%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachinesetresourcepolicy 81%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachinesnapshot 92%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachinewebconsolerequest 72%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachinewebconsolerequest/v1alpha1 72%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachinewebconsolerequest/v1alpha1/conditions 88%
github.com/vmware-tanzu/vm-operator/controllers/virtualmachinewebconsolerequest/v1alpha1/patch 78%
github.com/vmware-tanzu/vm-operator/controllers/vspherepolicy/policyevaluation 85%
github.com/vmware-tanzu/vm-operator/pkg/bitmask 100%
github.com/vmware-tanzu/vm-operator/pkg/builder 93%
github.com/vmware-tanzu/vm-operator/pkg/conditions 90%
github.com/vmware-tanzu/vm-operator/pkg/config 100%
github.com/vmware-tanzu/vm-operator/pkg/config/capabilities 98%
github.com/vmware-tanzu/vm-operator/pkg/config/env 100%
github.com/vmware-tanzu/vm-operator/pkg/context 22%
github.com/vmware-tanzu/vm-operator/pkg/context/generic 100%
github.com/vmware-tanzu/vm-operator/pkg/context/operation 100%
github.com/vmware-tanzu/vm-operator/pkg/crd 76%
github.com/vmware-tanzu/vm-operator/pkg/errors 76%
github.com/vmware-tanzu/vm-operator/pkg/exit 100%
github.com/vmware-tanzu/vm-operator/pkg/log 100%
github.com/vmware-tanzu/vm-operator/pkg/mem 100%
github.com/vmware-tanzu/vm-operator/pkg/patch 78%
github.com/vmware-tanzu/vm-operator/pkg/prober 89%
github.com/vmware-tanzu/vm-operator/pkg/prober/probe 90%
github.com/vmware-tanzu/vm-operator/pkg/prober/worker 77%
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere 75%
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/clustermodules 73%
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/config 88%
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/contentlibrary 76%
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/credentials 100%
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/network 82%
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/placement 69%
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/session 52%
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/storage 44%
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/upgrade/virtualmachine 96%
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/vcenter 85%
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/virtualmachine 86%
github.com/vmware-tanzu/vm-operator/pkg/providers/vsphere/vmlifecycle 72%
github.com/vmware-tanzu/vm-operator/pkg/record 87%
github.com/vmware-tanzu/vm-operator/pkg/topology 91%
github.com/vmware-tanzu/vm-operator/pkg/util 70%
github.com/vmware-tanzu/vm-operator/pkg/util/cloudinit 89%
github.com/vmware-tanzu/vm-operator/pkg/util/cloudinit/validate 91%
github.com/vmware-tanzu/vm-operator/pkg/util/image 100%
github.com/vmware-tanzu/vm-operator/pkg/util/kube 91%
github.com/vmware-tanzu/vm-operator/pkg/util/kube/cource 100%
github.com/vmware-tanzu/vm-operator/pkg/util/kube/internal 100%
github.com/vmware-tanzu/vm-operator/pkg/util/kube/proxyaddr 73%
github.com/vmware-tanzu/vm-operator/pkg/util/kube/spq 99%
github.com/vmware-tanzu/vm-operator/pkg/util/linuxprep 97%
github.com/vmware-tanzu/vm-operator/pkg/util/netplan 100%
github.com/vmware-tanzu/vm-operator/pkg/util/nil 100%
github.com/vmware-tanzu/vm-operator/pkg/util/ovfcache 75%
github.com/vmware-tanzu/vm-operator/pkg/util/ovfcache/internal 100%
github.com/vmware-tanzu/vm-operator/pkg/util/paused 100%
github.com/vmware-tanzu/vm-operator/pkg/util/ptr 100%
github.com/vmware-tanzu/vm-operator/pkg/util/resize 98%
github.com/vmware-tanzu/vm-operator/pkg/util/sysprep 98%
github.com/vmware-tanzu/vm-operator/pkg/util/vmopv1 90%
github.com/vmware-tanzu/vm-operator/pkg/util/volumes 100%
github.com/vmware-tanzu/vm-operator/pkg/util/vsphere/client 66%
github.com/vmware-tanzu/vm-operator/pkg/util/vsphere/datastore 100%
github.com/vmware-tanzu/vm-operator/pkg/util/vsphere/library 92%
github.com/vmware-tanzu/vm-operator/pkg/util/vsphere/storage 84%
github.com/vmware-tanzu/vm-operator/pkg/util/vsphere/vm 79%
github.com/vmware-tanzu/vm-operator/pkg/util/vsphere/watcher 85%
github.com/vmware-tanzu/vm-operator/pkg/vmconfig 95%
github.com/vmware-tanzu/vm-operator/pkg/vmconfig/anno2extraconfig 100%
github.com/vmware-tanzu/vm-operator/pkg/vmconfig/bootoptions 88%
github.com/vmware-tanzu/vm-operator/pkg/vmconfig/cdrom 88%
github.com/vmware-tanzu/vm-operator/pkg/vmconfig/crypto 91%
github.com/vmware-tanzu/vm-operator/pkg/vmconfig/diskpromo 100%
github.com/vmware-tanzu/vm-operator/pkg/vmconfig/policy 96%
github.com/vmware-tanzu/vm-operator/pkg/vmconfig/virtualcontroller 86%
github.com/vmware-tanzu/vm-operator/pkg/vmconfig/volumes/unmanaged/backfill 100%
github.com/vmware-tanzu/vm-operator/pkg/vmconfig/volumes/unmanaged/register 95%
github.com/vmware-tanzu/vm-operator/pkg/webconsolevalidation 100%
github.com/vmware-tanzu/vm-operator/services/vm-watcher 85%
github.com/vmware-tanzu/vm-operator/webhooks/common 98%
github.com/vmware-tanzu/vm-operator/webhooks/persistentvolumeclaim/validation 95%
github.com/vmware-tanzu/vm-operator/webhooks/unifiedstoragequota/validation 89%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachine/mutation 87%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachine/validation 94%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachineclass/mutation 62%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachineclass/validation 89%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachinegroup/mutation 87%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachinegroup/validation 92%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachinegrouppublishrequest/mutation 86%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachinegrouppublishrequest/validation 88%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachinepublishrequest/validation 93%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachinereplicaset/validation 90%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachineservice/mutation 67%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachineservice/validation 92%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachinesetresourcepolicy/validation 89%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachinesnapshot/mutation 83%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachinesnapshot/validation 91%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachinewebconsolerequest/v1alpha1/validation 92%
github.com/vmware-tanzu/vm-operator/webhooks/virtualmachinewebconsolerequest/validation 92%
Summary 82% (18121 / 21987)

Minimum allowed line rate is 79%

Copy link
Collaborator

@aruneshpa aruneshpa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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!

@aruneshpa aruneshpa merged commit 227b8f2 into vmware-tanzu:main Feb 3, 2026
25 checks passed
@hpannem hpannem deleted the topic/hpannem/ipv6fixes branch February 3, 2026 22:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/XL Denotes a PR that changes 500-999 lines.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants