Skip to content
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

Merged
merged 7 commits into from
Mar 15, 2023

Conversation

jaer-tsun
Copy link
Contributor

@jaer-tsun jaer-tsun commented Mar 13, 2023

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:

Comment on lines 113 to 116
ncgw = ncipnet.IP.Mask(ncipnet.Mask)
ncgw[3]++
if !ncipnet.Contains(ncgw) {
return IPAMAddResult{}, errors.Wrap(errInvalidArgs, "%w: Invalid gateway address "+ncgw.String())
}
Copy link
Member

@tamilmani1989 tamilmani1989 Mar 13, 2023

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?

Copy link
Contributor Author

@jaer-tsun jaer-tsun Mar 13, 2023

Choose a reason for hiding this comment

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

we were passing 169.254.1.1 to linux before too, and we just tested this change and it's working
image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

scoped to windows now

cni/network/invoker_cns.go Outdated Show resolved Hide resolved
@@ -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)
Copy link
Member

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

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) {
Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added

@tamilmani1989 tamilmani1989 added cni Related to CNI. fix Fixes something. labels Mar 15, 2023
@tamilmani1989 tamilmani1989 changed the title fix: CNI Overlay Gateway Bug fix: Windows CNI Overlay Gateway Bug Mar 15, 2023
@@ -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)}}
Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added

Comment on lines +415 to +417
ncgw := podsubnet.IP
ncgw[3]++
ncgw = net.ParseIP(ncgw.String())
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

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

@jaer-tsun jaer-tsun merged commit dac5b31 into Azure:master Mar 15, 2023
@jaer-tsun jaer-tsun deleted the tsch/fixOverlayGwBug branch March 15, 2023 20:01
@jaer-tsun jaer-tsun mentioned this pull request Mar 15, 2023
3 tasks
jpayne3506 pushed a commit that referenced this pull request Sep 11, 2023
* 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 <tsun.chu@microsoft.com>
(cherry picked from commit dac5b31)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cni Related to CNI. fix Fixes something.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants