Skip to content

csi: add scaffolding for node-specific restriction handling#5508

Open
mrhapile wants to merge 3 commits intofluid-cloudnative:masterfrom
mrhapile:csi-node-restriction-scaffold
Open

csi: add scaffolding for node-specific restriction handling#5508
mrhapile wants to merge 3 commits intofluid-cloudnative:masterfrom
mrhapile:csi-node-restriction-scaffold

Conversation

@mrhapile
Copy link

Ⅰ. Describe what this PR does

This PR introduces scaffolding in the CSI Node plugin to support future
node-specific restriction handling.

Specifically, it:

  • Adds a pluggable NodeRestrictionChecker abstraction
  • Wires a default no-op implementation into the CSI node server
  • Hooks restriction checking into NodePublishVolume for observability (logging only)

There is no behavior change in this PR. All volume publish operations
continue to function as before.

This lays the groundwork for enforcing node-level constraints (e.g. based on
node labels or annotations) in follow-up PRs.


Ⅱ. Does this pull request fix one issue?

NONE

(Related to #5315 , but does not close it as this PR only adds scaffolding.)


Ⅲ. List the added test cases (unit test/integration test) if any, please explain if no tests are needed.

No tests are added in this PR.

This change only introduces structural scaffolding and logging without
altering any functional behavior, so existing tests remain sufficient.
Future PRs that add enforcement logic will include corresponding tests.

Signed-off-by: mrhapile <allinonegaming3456@gmail.com>
Copilot AI review requested due to automatic review settings January 26, 2026 17:51
@fluid-e2e-bot
Copy link

fluid-e2e-bot bot commented Jan 26, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign cheyang for approval by writing /assign @cheyang in a comment. For more information see:The Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @mrhapile, 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 establishes foundational scaffolding within the CSI Node plugin to enable future implementation of node-specific restriction handling. It introduces an extensible NodeRestrictionChecker abstraction and integrates a no-op version into the NodePublishVolume flow for observability, without altering any current operational behavior. This work prepares the system for enforcing node-level constraints in subsequent development.

Highlights

  • New Abstraction: Introduced a NodeRestrictionChecker interface and a NodeRestriction struct to define node-level CSI constraints and a mechanism to fetch them.
  • Default Implementation: A noopRestrictionChecker is provided as a default, which currently allows all operations, ensuring no immediate behavior change.
  • Integration Point: The NodePublishVolume function in the node server now includes a call to the restrictionChecker for logging purposes, laying the groundwork for future enforcement.
  • No Behavior Change: This pull request explicitly makes no functional changes to existing volume publish operations, serving purely as scaffolding.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

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.

@fluid-e2e-bot
Copy link

fluid-e2e-bot bot commented Jan 26, 2026

Hi @mrhapile. Thanks for your PR.

I'm waiting for a fluid-cloudnative member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Copy link
Contributor

@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 introduces the scaffolding for node-specific restriction handling in the CSI Node plugin. It adds a NodeRestrictionChecker abstraction with a no-op implementation and integrates it into the NodePublishVolume operation for observability. The changes align with the PR description, laying the groundwork for future node-level constraint enforcement without altering current behavior.

// NodeRestriction represents node-level CSI constraints
type NodeRestriction struct {
CSIDisabled bool
MaxVolumes int
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The MaxVolumes field is an int. If a negative value is assigned in future implementations, it could lead to unexpected behavior (e.g., infinite volumes or panics). Consider using an unsigned integer type or adding validation to ensure it's non-negative if that's the intended constraint.

Copy link
Author

Choose a reason for hiding this comment

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

This PR only introduces scaffolding without enforcement. Validation logic will be added when restrictions are enforced in follow-up PRs.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds scaffolding to the CSI node plugin for future node-specific restriction enforcement by introducing a pluggable checker, wiring in a default no-op implementation, and emitting restriction-related logs during NodePublishVolume.

Changes:

  • Add NodeRestrictionChecker interface and a no-op implementation.
  • Store a restriction checker on the CSI node server and query it during NodePublishVolume (logging only).
  • Wire the default no-op checker into node server construction.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
pkg/csi/plugins/nodeserver.go Adds a restrictionChecker field and logs checker output during NodePublishVolume.
pkg/csi/plugins/node_restriction.go Introduces restriction types, checker interface, and a no-op checker implementation.
pkg/csi/plugins/driver.go Wires the no-op checker into the node server constructor.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 96 to 100
apiReader: d.apiReader,
nodeAuthorizedClient: d.nodeAuthorizedClient,
locks: d.locks,
locks: d.locks,
restrictionChecker: NewNoopRestrictionChecker(),
}
Copy link

Copilot AI Jan 26, 2026

Choose a reason for hiding this comment

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

This file appears to have gofmt issues (e.g., trailing whitespace after d.locks, in the struct literal). CI in this repo runs gofmt checks, so please run gofmt (or make fmt) to avoid formatting failures.

Copilot uses AI. Check for mistakes.
Comment on lines +11 to +14
// NodeRestrictionChecker fetches node restrictions
type NodeRestrictionChecker interface {
GetRestriction(nodeName string) (*NodeRestriction, error)
}
Copy link

Copilot AI Jan 26, 2026

Choose a reason for hiding this comment

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

NodeRestrictionChecker.GetRestriction takes a parameter named nodeName, but callers pass ns.nodeId. To avoid confusion for future implementations, consider renaming the parameter (and related comments) to nodeID/nodeIDOrName to match how it is actually used.

Copilot uses AI. Check for mistakes.
Copy link
Author

Choose a reason for hiding this comment

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

Thanks for the suggestion. Since this is scaffolding-only and not yet enforcing restrictions, I’ll keep the current naming for now and refine it in the enforcement phase if needed.

@codecov
Copy link

codecov bot commented Jan 27, 2026

Codecov Report

❌ Patch coverage is 0% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 56.87%. Comparing base (b663b53) to head (1cd1033).
⚠️ Report is 19 commits behind head on master.

Files with missing lines Patch % Lines
pkg/csi/plugins/nodeserver.go 0.00% 7 Missing ⚠️
pkg/csi/plugins/node_restriction.go 0.00% 5 Missing ⚠️
pkg/csi/plugins/driver.go 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5508      +/-   ##
==========================================
+ Coverage   56.82%   56.87%   +0.05%     
==========================================
  Files         443      444       +1     
  Lines       30735    30297     -438     
==========================================
- Hits        17464    17232     -232     
+ Misses      11717    11571     -146     
+ Partials     1554     1494      -60     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Signed-off-by: mrhapile <allinonegaming3456@gmail.com>
Signed-off-by: mrhapile <allinonegaming3456@gmail.com>
@sonarqubecloud
Copy link

@mrhapile
Copy link
Author

@TrafalgarZZZ can you tell me what changes can I make

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments