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: route issues on Swiftv2 Windows #3205

Open
wants to merge 41 commits into
base: master
Choose a base branch
from

Conversation

paulyufan2
Copy link
Contributor

@paulyufan2 paulyufan2 commented Nov 26, 2024

Reason for Change:

This is the long term solution to fix Swiftv2 Windows Routes issues to make sure windows cns gets all required cidrs from AKS.
Fixes include:
1.Windows CNS gets infravnet/pod/node cidrs from configs
2.Add these routes and send them to the CNI

Issue Fixed:

Background of the issue:
In Linux Swiftv2, CNS fetches infravnet/pod/node cidrs from the node's envs set by AKS; we should do same thing for Windows;

Requirements:

Require to validate this PR after AKS-RP PR to be merged

Notes:

@paulyufan2 paulyufan2 force-pushed the defaultroutelongtermsolution branch 2 times, most recently from 6683000 to ec4f810 Compare December 6, 2024 19:06
@paulyufan2 paulyufan2 force-pushed the defaultroutelongtermsolution branch from cd29e26 to 8077cd5 Compare December 12, 2024 22:17
@paulyufan2 paulyufan2 marked this pull request as ready for review December 12, 2024 22:51
@paulyufan2 paulyufan2 requested a review from a team as a code owner December 12, 2024 22:51
@paulyufan2 paulyufan2 requested a review from csfmomo December 12, 2024 22:51
@paulyufan2 paulyufan2 changed the title long-term solution for route issues windows long-term solution for route issues on Swiftv2 Windows Dec 12, 2024
@paulyufan2 paulyufan2 changed the title long-term solution for route issues on Swiftv2 Windows fix: route issues on Swiftv2 Windows Dec 12, 2024
@paulyufan2
Copy link
Contributor Author

/azp run Azure Container Networking PR

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link

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 Dec 27, 2024
Copy link

github-actions bot commented Jan 3, 2025

Pull request closed due to inactivity.

@github-actions github-actions bot closed this Jan 3, 2025
@github-actions github-actions bot deleted the defaultroutelongtermsolution branch January 3, 2025 00:01
@paulyufan2 paulyufan2 restored the defaultroutelongtermsolution branch January 6, 2025 18:11
@paulyufan2 paulyufan2 reopened this Jan 6, 2025
@github-actions github-actions bot removed the stale Stale due to inactivity. label Jan 7, 2025
@paulyufan2 paulyufan2 force-pushed the defaultroutelongtermsolution branch from 6b3eefc to 0213526 Compare January 7, 2025 16:24
@paulyufan2 paulyufan2 added the cns Related to CNS. label Jan 7, 2025
@paulyufan2 paulyufan2 force-pushed the defaultroutelongtermsolution branch 4 times, most recently from 1249211 to 272f829 Compare January 13, 2025 19:53
@paulyufan2
Copy link
Contributor Author

/azp run Azure Container Networking PR

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@paulyufan2 paulyufan2 force-pushed the defaultroutelongtermsolution branch from e9442c3 to 4f8ef4f Compare January 16, 2025 01:55
@paulyufan2
Copy link
Contributor Author

/azp run Azure Container Networking PR

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@paulyufan2 paulyufan2 requested a review from a team as a code owner January 21, 2025 22:47
@paulyufan2 paulyufan2 requested a review from a team as a code owner January 22, 2025 14:39
for i := range podIPInfo {
assert.DeepEqual(t, podIPInfo[i].Routes, desiredPodIPInfo[i].Routes)
reflect.DeepEqual(podIPInfo[i].Routes, desiredPodIPInfo[i].Routes)
Copy link
Member

Choose a reason for hiding this comment

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

Preference towards github.com/google/go-cmp/cmp.Equal over reflect.DeepEqual (it's a drop-in replacement)

Comment on lines +277 to +278
v4IPs = []string{}
v6IPs = []string{}
Copy link
Member

Choose a reason for hiding this comment

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

Don't use named returns please, they have surprising semantics. For example, these two lines are unnecessary since they are auto-initialized.

v6IPs = append(v6IPs, v6PodIPs...)

if ip.Is4() {
routes = append(routes, k.addRoutes(v4IPs, overlayGatewayv4)...)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm comparing the getInfraRoutes code in the _linux.go file and the getInfraRoutes code in the _windows.go file and noticed that overlayGatewayv4 / v6 is added in linux-- could you provide background on this (does it make an appearance in windows, and what is it used for?). Also the casing is inconsistent for v4 and V6

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, I think I added comments somewhere;
To sum up:
Linux: always use overlayGatewayv4 as the default gateway IP (168.x.x.x) for IPv4 and overlayGatewayv6 for IPv6; note that ipv6 is not supported for both Linux and Windows right now but codes already implemented ipv6 gateway and I will not touch it.

Windows: always use 0.0.0.0 as the default gateway IP for containerd to program the routing table and ipv6 is not supported.

Copy link
Contributor

Choose a reason for hiding this comment

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

thanks for clarifying, could we also add that note (regarding the gateway ip) above this function if it is still present after the refactor?

func (k *K8sSWIFTv2Middleware) assignSubnetPrefixLengthFields(_ *cns.PodIpInfo, _ v1alpha1.InterfaceInfo, _ string) error {
return nil
}
func (k *K8sSWIFTv2Middleware) getInfraRoutes(podIPInfo *cns.PodIpInfo) ([]cns.Route, error) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I noticed there is a lot of similar code between the windows and linux versions of getInfraRoutes-- would it be possible to move these to the common go file and then have another function that calls an OS specific implementation and returns all v4 and v6 cidrs for that particular OS?

Copy link
Contributor

Choose a reason for hiding this comment

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

if not could you add a comment to this function mentioning what it does in each OS implementation, since the behavior differs (ex: presence of overlayGateway IP, get pod cidrs in linux only, get cidrs (meaning node+service cidrs are added)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes Riya's PR has refactored the middlewire and I am waiting for her PR to be checked in and I will make changes on top of her PR

@@ -249,3 +249,59 @@ func (k *K8sSWIFTv2Middleware) getIPConfig(ctx context.Context, podInfo cns.PodI
func (k *K8sSWIFTv2Middleware) Type() cns.SWIFTV2Mode {
return cns.K8sSWIFTV2
}

// CNS gets pod CIDRs from configuration env and parse them to get the v4 and v6 IPs
// Containerd reassigns the IP to the adapter and kernel configures the pod cidr route by default, so windows swiftv2 does not require pod cidr
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel like the comment here would be better above the OS-specific implementations of getInfraRoutes. GetPodCidrs (the function) by itself doesn't do anything os-specific.

cns/middlewares/k8sSwiftV2_windows.go Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cns Related to CNS.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants