Skip to content

Sync defaultIPv6PrefixLength from VPCNetworkConfiguration to Subnet(Set)#1417

Open
wenqiq wants to merge 8 commits into
vmware-tanzu:mainfrom
wenqiq:topic/wenqi/VPCNetworkConfiguration-IPv6
Open

Sync defaultIPv6PrefixLength from VPCNetworkConfiguration to Subnet(Set)#1417
wenqiq wants to merge 8 commits into
vmware-tanzu:mainfrom
wenqiq:topic/wenqi/VPCNetworkConfiguration-IPv6

Conversation

@wenqiq
Copy link
Copy Markdown
Contributor

@wenqiq wenqiq commented Apr 26, 2026

Sync defaultIPv6PrefixLength from VPCNetworkConfiguration to Subnet(Set)

When a VPCNetworkConfiguration carries a defaultIPv6PrefixLength, propagate
it to newly created Subnet and SubnetSet resources so that dual-stack and
IPv6-only clusters receive the correct prefix length without requiring users
to set it manually on every resource.

TestDone:

1.Replace manager, Modify nsxop.ini and Restart the Operator
POD=$(kubectl -n vmware-system-nsx get pod -o name | head -1)
kubectl -n vmware-system-nsx exec $POD -- grep -A20 "[k8s]" /etc/nsx-ujo/ncp.ini
57e283f6-c9d7-4aa0-b57f-f6598d90d016

2.Create a Custom VPCNetworkConfiguration with defaultIPv6PrefixLength

NS_PROJECT=$(kubectl get vpcnetworkconfigurations system -o jsonpath='{.spec.nsxProject}')
PROFILE=$(kubectl get vpcnetworkconfigurations system -o jsonpath='{.spec.vpcConnectivityProfile}')
echo $PROFILE
/orgs/default/projects/project-quality/vpc-connectivity-profiles/default--47dfafa0-1896-498e-aca3-c952e522a2ad

kubectl get vpcnetworkconfigurations custom-nc-dualstack -o yaml
apiVersion: crd.nsx.vmware.com/v1alpha1
kind: VPCNetworkConfiguration
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"crd.nsx.vmware.com/v1alpha1","kind":"VPCNetworkConfiguration","metadata":{"annotations":{},"name":"custom-nc-dualstack"},"spec":{"defaultIPv6PrefixLength":96,"defaultSubnetSize":32,"nsxProject":"/orgs/default/projects/project-quality","privateIPs":["172.31.0.0/16"],"vpcConnectivityProfile":"/orgs/default/projects/project-quality/vpc-connectivity-profiles/default--47dfafa0-1896-498e-aca3-c952e522a2ad"}}
  creationTimestamp: "2026-05-12T11:29:22Z"
  generation: 2
  name: custom-nc-dualstack
  resourceVersion: "4395586"
  uid: b4fdf772-5a8c-4ff9-865f-82a11b8c4803
spec:
  defaultIPv6PrefixLength: 96
  defaultSubnetSize: 32
  nsxProject: /orgs/default/projects/project-quality
  privateIPs:
  - 172.31.0.0/16
  vpcConnectivityProfile: /orgs/default/projects/project-quality/vpc-connectivity-profiles/default--47dfafa0-1896-498e-aca3-c952e522a2ad
status:
  vpcs:
  - name: test-ns-dualstack_s3unh
    nsxLoadBalancerPath: /orgs/default/projects/project-quality/vpcs/test-ns-dualstack_s3unh/vpc-lbs/default
    vpcPath: /orgs/default/projects/project-quality/vpcs/test-ns-dualstack_s3unh
b070544d-bc0a-4dbe-83ec-00114856aa15

3.Create a Namespace Associated with the Custom NC

# test-ns-dualstack.yaml
apiVersion: v1
kind: Namespace
metadata:
  name: test-ns-dualstack
  annotations:
    nsx.vmware.com/vpc_network_config: custom-nc-dualstack

kubectl apply -f test-ns-dualstack.yaml

4.Verify the Namespace Was Associated Correctly

Check that the annotation was set

kubectl get namespace test-ns-dualstack -o jsonpath='{.metadata.annotations}'
{"kubectl.kubernetes.io/last-applied-configuration":"{\"apiVersion\":\"v1\",\"kind\":\"Namespace\",\"metadata\":{\"annotations\":{\"nsx.vmware.com/vpc_network_config\":\"custom-nc-dualstack\"},\"name\":\"test-ns-dualstack\"}}\n","nsx.vmware.com/vpc_network_config":"custom-nc-dualstack"}

Wait for NetworkInfo to become Ready

kubectl -n test-ns-dualstack get networkinfos -oyaml
apiVersion: v1
items:
- apiVersion: crd.nsx.vmware.com/v1alpha1
  kind: NetworkInfo
  metadata:
    creationTimestamp: "2026-05-12T11:55:47Z"
    generation: 2
    name: test-ns-dualstack
    namespace: test-ns-dualstack
    resourceVersion: "4395588"
    uid: 0bfd7adb-c66c-46c1-bd75-b417a0ce73d9
  vpcs:
  - defaultSNATIP: 192.168.0.8
    loadBalancerIPAddresses: 100.64.0.9
    name: test-ns-dualstack_s3unh
    networkStack: FullStackVPC
    privateIPs:
    - 172.31.0.0/16
kind: List
metadata:
  resourceVersion: ""

5.Verify SubnetSet Fields

kubectl -n test-ns-dualstack get subnetsets -o yaml
apiVersion: v1
items:
- apiVersion: crd.nsx.vmware.com/v1alpha1
  kind: SubnetSet
  metadata:
    creationTimestamp: "2026-05-12T11:55:50Z"
    generation: 2
    labels:
      nsx.vmware.com/default-network: pod
      nsxoperator.vmware.com/default-subnetset-for: Pod
    name: pod-default
    namespace: test-ns-dualstack
    resourceVersion: "4395584"
    uid: d1c11af2-9725-460f-bbde-3d5102d4ab2e
  spec:
    accessMode: PrivateTGW
    ipAddressType: IPV4IPV6
    ipv4SubnetSize: 32
    ipv6PrefixLength: 96
    subnetDHCPConfig:
      dhcpServerAdditionalConfig: {}
    subnetDHCPv6Config:
      dhcpv6ServerAdditionalConfig: {}
  status:
    conditions:
    - lastTransitionTime: "2026-05-12T11:55:50Z"
      message: SubnetSet CR has been successfully created/updated
      reason: SubnetSetReady
      status: "True"
      type: Ready
- apiVersion: crd.nsx.vmware.com/v1alpha1
  kind: SubnetSet
  metadata:
    creationTimestamp: "2026-05-12T11:55:50Z"
    generation: 2
    labels:
      nsx.vmware.com/default-network: vm
      nsxoperator.vmware.com/default-subnetset-for: VirtualMachine
    name: vm-default
    namespace: test-ns-dualstack
    resourceVersion: "4395578"
    uid: f388ab4f-9fad-4231-a506-15973d6dbdec
  spec:
    accessMode: Private
    ipAddressType: IPV4IPV6
    ipv4SubnetSize: 32
    ipv6PrefixLength: 96
    subnetDHCPConfig:
      dhcpServerAdditionalConfig: {}
    subnetDHCPv6Config:
      dhcpv6ServerAdditionalConfig: {}
  status:
    conditions:
    - lastTransitionTime: "2026-05-12T11:55:50Z"
      message: SubnetSet CR has been successfully created/updated
      reason: SubnetSetReady
      status: "True"
      type: Ready
kind: List
metadata:
  resourceVersion: ""
2a65fc9f-9a16-424a-ba45-931cd8aefca5

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 27, 2026

Codecov Report

❌ Patch coverage is 35.22727% with 57 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.20%. Comparing base (6ae0434) to head (faa7d0c).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
pkg/controllers/subnet/subnet_controller.go 6.25% 14 Missing and 1 partial ⚠️
pkg/util/ip.go 33.33% 8 Missing and 2 partials ⚠️
pkg/controllers/subnetset/subnetset_controller.go 11.11% 7 Missing and 1 partial ⚠️
pkg/config/config.go 40.00% 2 Missing and 4 partials ⚠️
pkg/controllers/common/utils.go 37.50% 1 Missing and 4 partials ⚠️
pkg/controllers/namespace/namespace_controller.go 58.33% 0 Missing and 5 partials ⚠️
.../controllers/networkinfo/networkinfo_controller.go 50.00% 1 Missing and 4 partials ⚠️
pkg/controllers/subnetset/subnetset_webhook.go 57.14% 0 Missing and 3 partials ⚠️

❌ Your patch status has failed because the patch coverage (35.22%) is below the target coverage (70.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1417      +/-   ##
==========================================
- Coverage   77.03%   75.20%   -1.84%     
==========================================
  Files         155      156       +1     
  Lines       22043    22134      +91     
==========================================
- Hits        16980    16645     -335     
- Misses       3858     3925      +67     
- Partials     1205     1564     +359     
Flag Coverage Δ
unit-tests 75.20% <35.22%> (-1.84%) ⬇️
Files with missing lines Coverage Δ
pkg/controllers/networkinfo/subnetset_handler.go 42.85% <100.00%> (-13.03%) ⬇️
pkg/controllers/subnetset/subnetset_webhook.go 52.38% <57.14%> (-25.99%) ⬇️
pkg/controllers/common/utils.go 78.93% <37.50%> (-5.77%) ⬇️
pkg/controllers/namespace/namespace_controller.go 59.06% <58.33%> (-12.64%) ⬇️
.../controllers/networkinfo/networkinfo_controller.go 51.91% <50.00%> (-18.76%) ⬇️
pkg/config/config.go 54.81% <40.00%> (-17.47%) ⬇️
pkg/controllers/subnetset/subnetset_controller.go 58.85% <11.11%> (-14.86%) ⬇️
pkg/util/ip.go 63.63% <33.33%> (-21.26%) ⬇️
pkg/controllers/subnet/subnet_controller.go 57.40% <6.25%> (-17.20%) ⬇️

... and 4 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@wenqiq wenqiq force-pushed the topic/wenqi/VPCNetworkConfiguration-IPv6 branch from c914a52 to c982df2 Compare April 29, 2026 04:21
@wenqiq wenqiq marked this pull request as ready for review April 29, 2026 04:22
@wenqiq wenqiq changed the title [WIP]Sync defaultIPv6PrefixLength from VPCNetworkConfiguration to Subnet(Set) Sync defaultIPv6PrefixLength from VPCNetworkConfiguration to Subnet(Set) Apr 29, 2026
Comment thread pkg/apis/vpc/v1alpha1/subnet_types.go
Comment thread pkg/controllers/namespace/namespace_controller.go Outdated
Comment thread pkg/controllers/namespace/namespace_controller.go Outdated
Comment thread pkg/controllers/networkinfo/networkinfo_controller.go Outdated
Comment thread pkg/controllers/networkinfo/networkinfo_controller.go Outdated
Comment thread pkg/controllers/common/utils.go Outdated
Comment thread pkg/controllers/subnet/subnet_controller.go Outdated
Comment thread pkg/controllers/subnet/subnet_controller.go Outdated
Comment thread pkg/controllers/subnetset/subnetset_controller.go Outdated
Comment thread pkg/controllers/subnetset/subnetset_controller.go Outdated
@wenqiq wenqiq force-pushed the topic/wenqi/VPCNetworkConfiguration-IPv6 branch from 257ab94 to e34a36b Compare May 10, 2026 19:35
Copy link
Copy Markdown
Collaborator

@dantingl dantingl left a comment

Choose a reason for hiding this comment

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

Please add testing done part.
I think we can do local test by creating VPCNetworkConfiguration CR manually and associate to a Namespace

Comment thread build/yaml/crd/vpc/crd.nsx.vmware.com_subnetsets.yaml
Comment thread build/yaml/crd/vpc/crd.nsx.vmware.com_subnetsets.yaml
Comment thread pkg/util/vpcnetworkconfiguration.go Outdated
Comment thread pkg/util/vpcnetworkconfiguration.go Outdated
Comment thread pkg/util/vpcnetworkconfiguration.go Outdated
Comment thread pkg/controllers/subnet/subnet_controller.go Outdated
Comment thread pkg/controllers/subnet/subnet_controller.go Outdated
Comment thread pkg/controllers/subnetset/subnetset_controller.go Outdated
Comment thread pkg/controllers/subnetset/subnetset_controller.go Outdated
Comment thread pkg/controllers/subnetset/subnetset_controller.go Outdated
@wenqiq wenqiq force-pushed the topic/wenqi/VPCNetworkConfiguration-IPv6 branch 2 times, most recently from d5ecc64 to 39ae06b Compare May 12, 2026 15:14
Comment thread pkg/config/config.go Outdated
Comment thread pkg/controllers/subnetset/subnetset_controller.go Outdated
Comment thread pkg/util/ip.go Outdated
@wenqiq wenqiq force-pushed the topic/wenqi/VPCNetworkConfiguration-IPv6 branch from 19e774d to c9c33a6 Compare May 15, 2026 02:08
Comment thread pkg/util/vpcnetworkconfiguration.go Outdated
Comment thread pkg/util/vpcnetworkconfiguration.go Outdated
Comment thread pkg/util/vpcnetworkconfiguration.go Outdated
Comment thread pkg/util/vpcnetworkconfiguration.go Outdated
Comment thread pkg/util/vpcnetworkconfiguration.go Outdated
Comment thread pkg/config/config.go Outdated
wenqiq added 5 commits May 15, 2026 10:41
Signed-off-by: Wenqi Qiu <wenqi.qiu@broadcom.com>
Signed-off-by: Wenqi Qiu <wenqi.qiu@broadcom.com>
Signed-off-by: Wenqi Qiu <wenqi.qiu@broadcom.com>
Signed-off-by: Wenqi Qiu <wenqi.qiu@broadcom.com>
Signed-off-by: Wenqi Qiu <wenqi.qiu@broadcom.com>
@wenqiq wenqiq force-pushed the topic/wenqi/VPCNetworkConfiguration-IPv6 branch from c9c33a6 to e096239 Compare May 15, 2026 03:22
Copy link
Copy Markdown
Contributor

@yanjunz97 yanjunz97 left a comment

Choose a reason for hiding this comment

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

Overall LGTM, just one comment

Comment thread pkg/util/ip.go Outdated
wenqiq added 3 commits May 15, 2026 14:27
Signed-off-by: Wenqi Qiu <wenqi.qiu@broadcom.com>
Signed-off-by: Wenqi Qiu <wenqi.qiu@broadcom.com>
Signed-off-by: Wenqi Qiu <wenqi.qiu@broadcom.com>
Copy link
Copy Markdown
Contributor

@yanjunz97 yanjunz97 left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants