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

feat: Dev stateless cni #2276

Merged
merged 10 commits into from
Dec 12, 2023
Merged

feat: Dev stateless cni #2276

merged 10 commits into from
Dec 12, 2023

Conversation

behzad-mir
Copy link
Contributor

@behzad-mir behzad-mir commented Oct 5, 2023

This PR includes all changes related to Stateless CNI in which CNS will manage and maintain the endpoint states.

  • There are changes related to CNS to add two new APIs with respect of endpoint state management.
    GetEndpoint() is used to return the state of a given endpointId. UpdateEndpoint() is used to update the HNSId and VethName field within the endpoint state.

  • The other changes are related to CNI and network package so the ADD/Del calls can be done without the use of statefile on Store package and instead use CNS and aformenetioned APIs.

  • uses conventional commit messages

  • includes documentation

  • adds unit tests

  • relevant PR labels added

@behzad-mir behzad-mir requested review from a team as code owners October 5, 2023 01:48
@behzad-mir behzad-mir requested a review from jaer-tsun October 5, 2023 01:48
@behzad-mir behzad-mir added cni Related to CNI. do-not-merge labels Oct 5, 2023
@behzad-mir behzad-mir force-pushed the Dev-Stateless-CNI branch 2 times, most recently from 427ed8d to 6c04d2d Compare October 5, 2023 02:54
@vipul-21
Copy link
Contributor

vipul-21 commented Oct 5, 2023

/azp run Azure Container Networking PR

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@behzad-mir behzad-mir requested a review from a team as a code owner October 18, 2023 20:39
@behzad-mir behzad-mir requested a review from vakalapa October 18, 2023 20:39
@behzad-mir behzad-mir force-pushed the Dev-Stateless-CNI branch 4 times, most recently from 1c40e0b to bfebb47 Compare October 18, 2023 23:47
@behzad-mir behzad-mir force-pushed the Dev-Stateless-CNI branch 2 times, most recently from bf03466 to 8f2cedf Compare November 1, 2023 20:08
@behzad-mir behzad-mir force-pushed the Dev-Stateless-CNI branch 5 times, most recently from 87d6ab0 to 85b217a Compare November 2, 2023 22:56
err = nil
return err
if !plugin.nm.IsStatelessCNIMode() {
Copy link
Contributor

Choose a reason for hiding this comment

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

do we need this check if it doesn't apply to stateless cni?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added a comment on top of it :
// this condition will not apply to stateless CNI since the network struct will be crated on each call

var logger = zapLog.CNILogger.With(zap.String("component", "cni-main"))

const (
hostNetAgentURL = "http://168.63.129.16/machine/plugins?comp=netagent&type=cnireport"
Copy link
Contributor

Choose a reason for hiding this comment

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

some of these look common across regular cni

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will be corrected on next commit

NetworkContainerID: epInfo.Id,
}
logger.Info("Deleting endpoint with", zap.String("Endpoint Info: ", epInfo.PrettyString()), zap.String("HNISID : ", ep.HnsId))
return nw.deleteEndpointImpl(netlink.NewNetlink(), platform.NewExecClient(logger), nil, nil, ep)
Copy link
Contributor

Choose a reason for hiding this comment

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

we'd need to pass endpoint with SecondaryInterfaceInfo for deletion as well

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is only going to cover stateless CNI for single Tenancy

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 are not covering Swift 2.0 at this point

Copy link
Member

Choose a reason for hiding this comment

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

if we address swift 2.0, then we dont need to care about migration for swift2.0 later.. Not in this PR, probably a different PR

tamilmani1989
tamilmani1989 previously approved these changes Nov 29, 2023
Copy link
Contributor

@rbtr rbtr left a comment

Choose a reason for hiding this comment

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

few minor comments. it would be easier to review if we scoped the changes to smaller PRs container only CNS and only CNI

Makefile Outdated Show resolved Hide resolved
Comment on lines +84 to +85
endpointStoreLocationLinux = "/var/run/azure-cns/"
endpointStoreLocationWindows = "/k/azurecns/"
Copy link
Contributor

Choose a reason for hiding this comment

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

/var/run/azure-cns is a legal file path (in Go) on Windows, do we need to differentiate this? maybe it should just be required that it comes from the config? If we must do this though, we shouldn't put multiplatform variables in main/the same file - they need to be in _linux.go, _windows.go etc

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I used that path at first but store package showed error and couldn't create the endpoint file.

Copy link
Contributor

Choose a reason for hiding this comment

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

then it needs to come from config instead of being hardcoded. we could have config_linux.go and config_windows.go to populate defaults if it is not set

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 also already made the AgentBaker changes according to k/azurecns directory since it was provided int he CNS Configmap for Windows. I simply applied the value form the configmap

cns/restserver/ipam.go Outdated Show resolved Hide resolved
behzad-mir and others added 9 commits December 8, 2023 10:14
#2102)

* Adding getEndpoint and UpdateEndpoint API to CNS with the respective clients in support of stateless CNI.

* Updating the unit tests and address the comments.

* Addressing the comments.

* Addressing the coments regarding CNS support for Stateless CNI

* Adddressing the PR comments
…package. (#2197)

* Apllying stateless CNI mode in network package.

* Addresing the commetns.
tamilmani1989
tamilmani1989 previously approved these changes Dec 8, 2023
@behzad-mir behzad-mir enabled auto-merge (squash) December 8, 2023 21:18
Copy link
Contributor

@rbtr rbtr left a comment

Choose a reason for hiding this comment

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

unblocking but let's revisit the windows/linux state file path (and how it comes from config). the hardcoded paths can't stay

@behzad-mir
Copy link
Contributor Author

/azp run Azure Container Networking PR

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@behzad-mir behzad-mir merged commit c4fe3a8 into master Dec 12, 2023
79 checks passed
@behzad-mir behzad-mir deleted the Dev-Stateless-CNI branch December 12, 2023 00:15
paulyufan2 pushed a commit that referenced this pull request Dec 18, 2023
* feat: 🌈 StatelessCNI: Adding getEndpoint and UpdateEndpoint API to CNS (#2102)

* Adding getEndpoint and UpdateEndpoint API to CNS with the respective clients in support of stateless CNI.

* Updating the unit tests and address the comments.

* Addressing the comments.

* Addressing the coments regarding CNS support for Stateless CNI

* Adddressing the PR comments

* 🌈 feat: adding flags for stateless cni (#2103)

feat: stateless cni

* 🌈 feat: StatelessCNI: Applying stateless CNI mode changes in network package. (#2197)

* Apllying stateless CNI mode in network package.

* Addresing the commetns.

* feat: create stateless cni binary for swift (#2275)

* enabling CNS telemetry

* Master rebase changes

* CNI Telemetry enabled on CNS

* Stateless CNI changes.

* making change to CNSendpointStorePath

* Updating makefile to avoid creating statless CNI release.

---------

Co-authored-by: Vipul Singh <vipul21sept@gmail.com>
matmerr pushed a commit that referenced this pull request Jan 17, 2024
* feat: 🌈 StatelessCNI: Adding getEndpoint and UpdateEndpoint API to CNS (#2102)

* Adding getEndpoint and UpdateEndpoint API to CNS with the respective clients in support of stateless CNI.

* Updating the unit tests and address the comments.

* Addressing the comments.

* Addressing the coments regarding CNS support for Stateless CNI

* Adddressing the PR comments

* 🌈 feat: adding flags for stateless cni (#2103)

feat: stateless cni

* 🌈 feat: StatelessCNI: Applying stateless CNI mode changes in network package. (#2197)

* Apllying stateless CNI mode in network package.

* Addresing the commetns.

* feat: create stateless cni binary for swift (#2275)

* enabling CNS telemetry

* Master rebase changes

* CNI Telemetry enabled on CNS

* Stateless CNI changes.

* making change to CNSendpointStorePath

* Updating makefile to avoid creating statless CNI release.

---------

Co-authored-by: Vipul Singh <vipul21sept@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cni Related to CNI.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants