-
Notifications
You must be signed in to change notification settings - Fork 242
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Windows CNI Overlay Gateway Bug #1849
Conversation
82951ac
to
b912dde
Compare
cni/network/invoker_cns.go
Outdated
ncgw = ncipnet.IP.Mask(ncipnet.Mask) | ||
ncgw[3]++ | ||
if !ncipnet.Contains(ncgw) { | ||
return IPAMAddResult{}, errors.Wrap(errInvalidArgs, "%w: Invalid gateway address "+ncgw.String()) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we scope this change only for windows and return overlayGWIP for linux as like before to make sure not introducing new change in linux?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
scoped to windows now
… initializing node because it couldn't reach IMDS
1c8c937
to
63e37a2
Compare
cni/network/network.go
Outdated
@@ -538,7 +538,7 @@ func (plugin *NetPlugin) Add(args *cniSkel.CmdArgs) error { | |||
logAndSendEvent(plugin, fmt.Sprintf("[cni-net] Created network %v with subnet %v.", networkID, ipamAddResult.hostSubnetPrefix.String())) | |||
} | |||
|
|||
natInfo := getNATInfo(nwCfg.ExecutionMode, options[network.SNATIPKey], nwCfg.MultiTenancy, enableSnatForDNS) | |||
natInfo := getNATInfo(nwCfg.ExecutionMode, nwCfg.IPAM.Mode, options[network.SNATIPKey], nwCfg.MultiTenancy, enableSnatForDNS) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can pass nwCfg pointer instead of individual fields
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
cni/network/network_windows.go
Outdated
func getNATInfo(executionMode string, ncPrimaryIPIface interface{}, multitenancy, enableSnatForDNS bool) (natInfo []policy.NATInfo) { | ||
if executionMode == string(util.V4Swift) { | ||
func getNATInfo(executionMode, ipamMode string, ncPrimaryIPIface interface{}, multitenancy, enableSnatForDNS bool) (natInfo []policy.NATInfo) { | ||
if executionMode == string(util.V4Swift) && ipamMode != string(util.V4Overlay) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add UT for this scenario for overlay vs podsubnet?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added
@@ -1068,3 +1079,9 @@ func TestGetNetworkName(t *testing.T) { | |||
}) | |||
} | |||
} | |||
|
|||
func TestGetOverlayNatInfo(t *testing.T) { | |||
nwCfg := &cni.NetworkConfig{ExecutionMode: string(util.V4Swift), IPAM: cni.IPAM{Mode: string(util.V4Overlay)}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you also add one case for swift podsubnet?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added
ncgw := podsubnet.IP | ||
ncgw[3]++ | ||
ncgw = net.ParseIP(ncgw.String()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check this out: https://stackoverflow.com/a/31191775
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we're passing the IP from net.IPNet instead of podip
* fix overlay gatway bug that prevented cloud-node-manager-windows from initializing node because it couldn't reach IMDS * add overlay invoker cns test * use parseip instead of mask * scope CNI overlay gateway bug fix to windows only * update test * adding UT to verify overlay NAT info is empty * add podsubnet netInfo test --------- Co-authored-by: Jaeryn <[email protected]> (cherry picked from commit dac5b31)
Reason for Change:
Fixing overlay gateway bug that prevented cloud-node-manager-windows from initializing node because it couldn't reach IMDS. An additional VFP rule was implicitly plumbed by HNS to add 169.254.1.1/16 to the exception list. This is most likely based off the RouteConfiguration in the "azure" HNS network. This additional VFP rule was skipping SNAT for any IP address in this range 169.254.0.0-169.254.255.255. We'll set the first .1 IP of podcidr as the gateway now.
Issue Fixed:
Requirements:
Notes: