Skip to content

fix: setdir in CNI client #2027

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

Merged
merged 1 commit into from
Jun 21, 2023
Merged

fix: setdir in CNI client #2027

merged 1 commit into from
Jun 21, 2023

Conversation

rbtr
Copy link
Contributor

@rbtr rbtr commented Jun 21, 2023

Reason for Change:

Sets the working directory when CNS invokes the CNI (only on Windows) so that the CNS reconcile from CNI finds the real CNI statefile and reinitializes the CNS state correctly.

Issue Fixed:

Due to the lack of CNIRuntimePath set when CNI is running on Windows: when CNS invokes CNI to restore state during initialization on Windows, it looks for the statefile in the local directory (.\azure-vnet.json) instead of the absolute path at C:\k\azure-vnet.json. No statefile exists in the current directory, so the CNI returns empty PodInfo to CNS, leading CNS to think there are no Pods scheduled and that all of its IPs are available.

Running a CNS built with this change, we can see that it finds the CNI statefile and correctly restores from it:

2023/06/21 18:11:58 [17776] Initializing from CNI
2023/06/21 18:11:58 [17776] Setting cmd to CNI_COMMAND=GET_ENDPOINT_STATE
2023/06/21 18:11:58 [17776] Reconciling initial CNS state as PodInfoByIP is not empty: 19
2023/06/21 18:11:58 [17776] reconciling initial CNS state attempt: 1

restoring CNS to the previous version and restarting shows that the statefile is not used:

2023/06/21 18:13:54 [124] Initializing from CNI
2023/06/21 18:13:54 [124] Setting cmd to CNI_COMMAND=GET_ENDPOINT_STATE
[no reconcile logs]
2023/06/21 18:13:56 [124] initialized and started IPAM pool monitor

Requirements:

Notes:

@rbtr rbtr added bug cns Related to CNS. cni Related to CNI. swift Related to SWIFT networking. overlay Related to Overlay networking. fix Fixes something. labels Jun 21, 2023
@rbtr rbtr self-assigned this Jun 21, 2023
so invoking from inside the CNS Pod works on Windows

Signed-off-by: Evan Baker <[email protected]>
@rbtr rbtr force-pushed the fix/win-cni-client branch from 812f3b7 to 9bdec36 Compare June 21, 2023 19:39
@rbtr rbtr marked this pull request as ready for review June 21, 2023 19:40
@rbtr rbtr requested a review from a team as a code owner June 21, 2023 19:40
@rbtr rbtr requested a review from sheylatrudo June 21, 2023 19:40
@rbtr rbtr enabled auto-merge (squash) June 21, 2023 19:40
@rbtr rbtr merged commit 5caf8d2 into Azure:master Jun 21, 2023
@rbtr rbtr deleted the fix/win-cni-client branch June 21, 2023 22:07
@@ -30,7 +24,7 @@ func New(exec utilexec.Interface) *client {

func (c *client) GetEndpointState() (*api.AzureCNIState, error) {
cmd := c.exec.Command(platform.CNIBinaryPath)

cmd.SetDir(CNIExecDir)
Copy link
Member

Choose a reason for hiding this comment

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

add a comment to say this work in windows only if state exists in c:\k

@@ -30,7 +24,7 @@ func New(exec utilexec.Interface) *client {

func (c *client) GetEndpointState() (*api.AzureCNIState, error) {
cmd := c.exec.Command(platform.CNIBinaryPath)

cmd.SetDir(CNIExecDir)
Copy link
Member

Choose a reason for hiding this comment

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

if CNIExecDir is empty, SetDir will skip setting directory?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

jaer-tsun pushed a commit to jaer-tsun/azure-container-networking that referenced this pull request Jul 17, 2023
so invoking from inside the CNS Pod works on Windows

Signed-off-by: Evan Baker <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug cni Related to CNI. cns Related to CNS. fix Fixes something. overlay Related to Overlay networking. swift Related to SWIFT networking.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants