Skip to content

[DRAFTPOND] test image for windows#4287

Open
csfmomo wants to merge 12 commits intomasterfrom
shchen/windowsimage
Open

[DRAFTPOND] test image for windows#4287
csfmomo wants to merge 12 commits intomasterfrom
shchen/windowsimage

Conversation

@csfmomo
Copy link
Copy Markdown
Contributor

@csfmomo csfmomo commented Mar 24, 2026

Reason for Change:

Issue Fixed:

Requirements:

Notes:

@csfmomo csfmomo requested a review from a team as a code owner March 24, 2026 19:37
@csfmomo csfmomo requested review from Copilot and timraymond March 24, 2026 19:37
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR extends NodeNetworkConfig → CNS request conversion to carry an IPv6 subnet alongside the existing IPv4 subnet, enabling dual-stack network container provisioning paths (including Windows).

Changes:

  • Add IPSubnetV6 to cns.IPConfiguration.
  • Populate IPSubnetV6 during dynamic/static NC → CreateNetworkContainerRequest conversion (Linux + Windows helpers).
  • Add unit tests covering IPv6 subnet parsing for both dynamic and static conversion.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
cns/kubecontroller/nodenetworkconfig/conversion.go Builds IPConfiguration with optional IPv6 subnet and passes IPv6 subnet into static helper.
cns/kubecontroller/nodenetworkconfig/conversion_linux.go Extends static helper signature and writes IPSubnetV6 into request.
cns/kubecontroller/nodenetworkconfig/conversion_windows.go Extends static helper signature and writes IPSubnetV6 into request.
cns/kubecontroller/nodenetworkconfig/conversion_test.go Adds tests for IPv6 subnet parsing for dynamic/static conversions.
cns/NetworkContainerContract.go Adds IPSubnetV6 field to IPConfiguration contract struct.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +59 to +62
ipConfig := cns.IPConfiguration{
IPSubnet: subnet,
GatewayIPAddress: nc.DefaultGateway,
}
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

CreateNCRequestFromDynamicNC populates IPSubnetV6 when SubnetAddressSpaceV6 is set, but never sets GatewayIPv6Address on the request IPConfiguration (it’s not in the initial ipConfig literal and not assigned in the IPv6 block). This means callers providing DefaultGatewayV6 won’t have it propagated, breaking IPv6 routing for dynamic NCs. Set ipConfig.GatewayIPv6Address from nc.DefaultGatewayV6 (likely gated the same way as SubnetAddressSpaceV6).

Copilot uses AI. Check for mistakes.
Comment on lines +64 to +73
if nc.SubnetAddressSpaceV6 != "" {
subnetV6Prefix, err := netip.ParsePrefix(nc.SubnetAddressSpaceV6)
if err != nil {
return nil, errors.Wrapf(err, "invalid SubnetAddressSpaceV6 %s", nc.SubnetAddressSpaceV6)
}
ipConfig.IPSubnetV6 = cns.IPSubnet{
IPAddress: nc.PrimaryIPV6,
PrefixLength: uint8(subnetV6Prefix.Bits()), //#nosec G115 -- prefix bits are 0-128, fits uint8
}
}
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

The IPv6 branch accepts any syntactically valid CIDR in SubnetAddressSpaceV6 (including IPv4 CIDRs) and copies PrimaryIPV6 into IPSubnetV6 without validating it’s a real IPv6 address or even non-empty. This can produce an invalid CreateNetworkContainerRequest that won’t be caught by CNS validation (Validate currently only checks GatewayIPAddress). Consider: (1) require subnetV6Prefix.Addr().Is6(), (2) netip.ParseAddr on nc.PrimaryIPV6 and ensure Is6(), and (3) return a clear error if PrimaryIPV6 is missing/invalid when SubnetAddressSpaceV6 is set.

Copilot uses AI. Check for mistakes.
Comment on lines +120 to +121
subnetV6 = cns.IPSubnet{
IPAddress: nc.PrimaryIPV6,
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

Static NC IPv6 handling has the same issue as dynamic: SubnetAddressSpaceV6 is parsed but not checked to be IPv6, and PrimaryIPV6 is copied into subnetV6 without validating it’s present/valid. If SubnetAddressSpaceV6 is accidentally set to an IPv4 CIDR or PrimaryIPV6 is empty/invalid, the request will contain a malformed IPSubnetV6. Add Is6()/ParseAddr validation and fail fast with a helpful error.

Suggested change
subnetV6 = cns.IPSubnet{
IPAddress: nc.PrimaryIPV6,
if !subnetV6Prefix.Addr().Is6() {
return nil, errors.Errorf("invalid SubnetAddressSpaceV6 %s: not an IPv6 prefix", nc.SubnetAddressSpaceV6)
}
if nc.PrimaryIPV6 == "" {
return nil, errors.Wrapf(ErrInvalidPrimaryIP, "empty PrimaryIPV6 for SubnetAddressSpaceV6 %s", nc.SubnetAddressSpaceV6)
}
primaryV6Addr, e := netip.ParseAddr(nc.PrimaryIPV6)
if e != nil {
return nil, errors.Wrapf(ErrInvalidPrimaryIP, "invalid PrimaryIPV6 %s", nc.PrimaryIPV6)
}
if !primaryV6Addr.Is6() {
return nil, errors.Wrapf(ErrInvalidPrimaryIP, "PrimaryIPV6 %s is not an IPv6 address", nc.PrimaryIPV6)
}
subnetV6 = cns.IPSubnet{
IPAddress: primaryV6Addr.String(),

Copilot uses AI. Check for mistakes.
Comment on lines +230 to +244
func TestCreateNCRequestFromDynamicNCWithIPv6(t *testing.T) {
nc := v1alpha.NetworkContainer{
ID: ncID,
PrimaryIP: primaryIP,
PrimaryIPV6: "fd12:3456:789a::1",
SubnetAddressSpace: subnetAddressSpace,
SubnetAddressSpaceV6: "fd12:3456:789a::/48",
DefaultGateway: defaultGateway,
NodeIP: nodeIP,
Version: version,
}
got, err := CreateNCRequestFromDynamicNC(nc)
require.NoError(t, err)
assert.Equal(t, cns.IPSubnet{IPAddress: "fd12:3456:789a::1", PrefixLength: 48}, got.IPConfiguration.IPSubnetV6)
}
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

The new IPv6 tests only assert IPSubnetV6 and don’t set/verify DefaultGatewayV6 -> GatewayIPv6Address propagation. Since dynamic conversion currently drops GatewayIPv6Address entirely, adding DefaultGatewayV6 to the test input and asserting got.IPConfiguration.GatewayIPv6Address would prevent regressions here.

Copilot uses AI. Check for mistakes.
Comment on lines 406 to 410
IPSubnet IPSubnet
IPSubnetV6 IPSubnet
DNSServers []string
GatewayIPAddress string
GatewayIPv6Address string
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

Adding IPSubnetV6 to IPConfiguration introduces new IPv6 data paths, but CreateNetworkContainerRequest.Validate() currently only validates GatewayIPAddress and doesn’t validate GatewayIPv6Address/IPSubnetV6 at all. Consider extending validation to cover the new IPv6 fields when they’re set so malformed IPv6 values fail early with a clear error.

Copilot uses AI. Check for mistakes.
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 8, 2026

This pull request is stale because it has been open for 2 weeks with no activity. Remove stale label or comment or this will be closed in 7 days

@github-actions github-actions bot added the stale Stale due to inactivity. label Apr 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stale Stale due to inactivity.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants