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

CNS - consider multiple IPs for a pod in reconciliation after restart #2079

Merged
merged 9 commits into from
Aug 2, 2023
Merged

CNS - consider multiple IPs for a pod in reconciliation after restart #2079

merged 9 commits into from
Aug 2, 2023

Conversation

ramiro-gamarra
Copy link
Contributor

@ramiro-gamarra ramiro-gamarra commented Jul 26, 2023

Reason for Change:

Reconciliation after CNS restart is currently not handling dual stack scenarios correctly. There's 2 bugs:

  • the information fetched from CNI currently filters out ipv6 addresses.
  • reconciliation after restart processes multiple NCs separately, but pod info in CNS (or at least one representation of it) is not able to be patched after first insertion, meaning, a pod will be reconciliated with ipv4 first, and then skip the update with ipv6.

This PR modifies the main reconciliation function such that it takes multiple NCs as input, and processes all IPs for a single pod key (interface or name+namespace, depending on reconcile flow) at the same time, such that both ipv4 and ipv6 can be inserted once as DesiredIPAddresses.

@ramiro-gamarra ramiro-gamarra requested a review from a team as a code owner July 26, 2023 01:05
@@ -325,6 +342,24 @@ func (service *HTTPRestService) ReconcileNCState(ncRequest *cns.CreateNetworkCon
return 0
}

func podInfoByIPToPodInfoExtByInterfaceID(podInfoByIP map[string]cns.PodInfo) map[string]podInfoExt {
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 comment explaining the purpose of this func?

@rbtr rbtr added cns Related to CNS. swift Related to SWIFT networking. labels Jul 27, 2023
// to pod IPs indexed by pod key (interface or name+namespace, depending on scenario):
//
// {
// "aaa-eth0": podIPs{IPs:["10.0.0.1","fe80::1"]}
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 pls update this to reflect the latest changes such as ipv4, ipv6?

ashvindeodhar
ashvindeodhar previously approved these changes Aug 1, 2023
@ramiro-gamarra ramiro-gamarra enabled auto-merge (squash) August 1, 2023 23:00
@ramiro-gamarra ramiro-gamarra merged commit c8005ed into Azure:master Aug 2, 2023
paulyufan2 pushed a commit that referenced this pull request Aug 2, 2023
…#2079)

* modifying reconcile function to take multiple ncs instead of one. we need this because for reconciliation in dual stack cases both IPs for a pod which can come from distinct ncs must be added at the same time

* adding comments, and renaming functions and types, to make the intent clearer

* adding some dummy values to cns.NewPodInfo invocations in tests, instead of empty strings since we need distinct interface ids

* adding a basic test for dual stack reconciliation

* adding validation for multiple ips for the same ip family on the same pod, which is not allowed

* changing direct use of interface id to pod key, which is better for reconcile flows using information from kubernetes instead of cni

* fixing comments to use host network terminology instead of system pod

* improving error message on duplicate ip from cni found; improving readability of error handling on ip parsing

* only checking for pod ips that are actually set on a pod
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cns Related to CNS. swift Related to SWIFT networking.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants