Skip to content

Fix thick plugin STATUS and GC handling for plugin-level commands#1490

Open
tsorya wants to merge 2 commits intok8snetworkplumbingwg:masterfrom
tsorya:jkary-fix-status-gc-no-pod-context
Open

Fix thick plugin STATUS and GC handling for plugin-level commands#1490
tsorya wants to merge 2 commits intok8snetworkplumbingwg:masterfrom
tsorya:jkary-fix-status-gc-no-pod-context

Conversation

@tsorya
Copy link

@tsorya tsorya commented Mar 16, 2026

Opening new PR for #1480

STATUS and GC are plugin-level commands with no pod context per the
CNI 1.1.0 spec. The thick plugin daemon incorrectly required
CNI_CONTAINERID, CNI_NETNS, and K8S_POD_NAME/K8S_POD_NAMESPACE for
these commands, causing failures when invoked by kubelet.

jkary and others added 2 commits March 16, 2026 16:52
STATUS and GC are plugin-level commands with no pod context per the
CNI 1.1.0 spec. The thick plugin daemon incorrectly required
CNI_CONTAINERID, CNI_NETNS, and K8S_POD_NAME/K8S_POD_NAMESPACE for
these commands, causing failures when invoked by kubelet.

Signed-off-by: Jason Kary <jkary@redhat.com>
- Check os.OpenFile error in STATUS/GC test
- Document that k8sArgs may be nil for STATUS/GC in HandleCNIRequest

Made-with: Cursor
@gemini-code-assist
Copy link

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a critical issue in the Multus CNI thick plugin where STATUS and GC commands failed when invoked by kubelet. The fix ensures that these commands, which are defined as plugin-level operations in the CNI 1.1.0 specification, no longer incorrectly require pod-specific context such as container ID, network namespace, or Kubernetes pod details. This change improves compliance with the CNI specification and enhances the robustness of the Multus CNI plugin's lifecycle management.

Highlights

  • CNI Command Handling: Corrected CNI STATUS and GC command handling in the thick plugin to align with CNI 1.1.0 specification, which defines them as plugin-level commands without pod context.
  • Conditional Argument Extraction: Modified the CNI request handler to conditionally extract Kubernetes runtime arguments, skipping them for STATUS and GC commands.
  • Environment Variable Requirements: Updated the extractCniData function to no longer require CNI_CONTAINERID, CNI_NETNS, or CNI_ARGS for STATUS and GC commands.
  • Removed Pod Context Checks: Removed erroneous checks for K8S_POD_NAMESPACE and K8S_POD_NAME within the cmdGC and cmdStatus functions.
  • New Test Cases: Introduced new unit tests to validate the successful execution of STATUS and GC commands when invoked without pod-specific CNI environment variables.
  • CNI Version Compliance: Ensured conflistStatus returns nil for CNI versions older than 1.1.0, preventing unnecessary processing.
Changelog
  • pkg/multus/multus.go
    • Added a return nil statement when conflistStatus is called with a CNI version less than 1.1.0.
  • pkg/server/server.go
    • Updated HandleCNIRequest to include a comment noting that k8sArgs may be nil for plugin-level commands.
    • Modified handleCNIRequest to conditionally extract Kubernetes runtime arguments, skipping them for STATUS and GC commands.
    • Adjusted extractCniData to bypass requirements for CNI_CONTAINERID, CNI_NETNS, and CNI_ARGS for STATUS and GC commands.
    • Removed checks for K8S_POD_NAMESPACE and K8S_POD_NAME from cmdGC and cmdStatus functions.
  • pkg/server/thick_cni_test.go
    • Added a new test context to verify STATUS and GC commands succeed without pod context, including cases where CNI_ARGS is unset or empty.
Activity
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request correctly adjusts the handling of STATUS and GC commands in the thick CNI plugin to align with the CNI 1.1.0 spec, which defines them as plugin-level commands without pod context. The changes prevent the server from incorrectly requiring pod-specific environment variables for these commands. The implementation looks correct and is well-tested. I've provided a few suggestions to improve code clarity, maintainability, and reduce duplication in tests.

Copy link
Contributor

@trozet trozet left a comment

Choose a reason for hiding this comment

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

thanks. Sorry i missed this in my original PR.

@trozet
Copy link
Contributor

trozet commented Mar 17, 2026

@bpickard22 can you PTAL?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants