Skip to content

feat(csi): add no-credentials (anonymous) connection mode#89

Open
ankitmaster08 wants to merge 1 commit into
mainfrom
feat-msfs-csi-anonymous-auth
Open

feat(csi): add no-credentials (anonymous) connection mode#89
ankitmaster08 wants to merge 1 commit into
mainfrom
feat-msfs-csi-anonymous-auth

Conversation

@ankitmaster08

@ankitmaster08 ankitmaster08 commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds an opt-in no-credentials / anonymous connection mode to the MSFS CSI driver and the core S3 backend (NGCDP-9029; follow-up to #84). This is Shane's clarified "empty secret" ask — connect with no creds of any kind (no IRSA, no access keys), e.g. a local AIS cluster or a public S3 bucket.

  • CSI: volumeAttributes.authType: none (alias anonymous) → no Secret, no IRSA, no AWS env vars injected, per-workload identity bypassed. S3 mounts emit anonymous: true; AIStore mounts are left with an empty token.
  • Core S3: new anonymous config field; the parser no longer requires access_key_id/secret_access_key when it is set, and setupS3Context installs aws.AnonymousCredentials{} so requests are unsigned. Rejected for live change via SIGHUP, consistent with the other S3 fields.
  • Fully backward compatible — auto / static / irsa behavior is unchanged.

Test plan

  • go build / go vet / gofmt clean (CSI + MSFS modules)
  • CSI unit tests: none/anonymous resolution, S3 emits anonymous: true, AIStore omits token/anonymous, buildEnv injects nothing, workload-identity no-op
  • MSFS unit test: anonymous S3 backend parses with no access keys
  • (manual) mount a public S3 bucket / local AIS cluster with authType: none

Tracked by NGCDP-9029.

Summary by CodeRabbit

  • New Features

    • Added an anonymous/no-credentials mode for S3-backed storage and CSI volume setup.
    • Expanded auth mode options to include none and anonymous alongside existing credential modes.
  • Bug Fixes

    • Reloaded configuration now blocks changes to the S3 anonymous setting during live updates.
    • Credential handling now avoids sending access keys when anonymous mode is selected.
  • Documentation

    • Updated CSI and chart docs to describe the new auth mode and its behavior.

Add authType=none (alias anonymous) to the CSI driver: no Secret, no IRSA,
and no AWS env vars are injected, and per-workload identity is bypassed. For
S3 the generated msfs.yaml sets anonymous: true; for AIStore the token is
left empty (anonymous access, e.g. a local AIS cluster).

Wire S3 anonymous support in the core: a new S3 "anonymous" config field
(the parser skips the access-key requirement) drives aws.AnonymousCredentials
so the SDK issues unsigned requests for public / no-auth endpoints. The field
is rejected for change via SIGHUP, consistent with the other S3 fields.

Adds unit tests (CSI none-mode resolution / config rendering / env, and
anonymous S3 config parsing) and documents the mode in the CSI README and
Helm chart.

NGCDP-9029
@ankitmaster08 ankitmaster08 requested a review from a team June 29, 2026 21:17
@coderabbitai

coderabbitai Bot commented Jun 29, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a new anonymous/none credential mode for S3 backends. The backendConfigS3Struct gains an anonymous boolean field; config parsing clears credentials when it is set; the S3 SDK wiring installs aws.AnonymousCredentials; and the CSI driver's credential-mode resolution, msfs.yaml generation, and workload-identity logic all handle the new mode. Tests and docs are updated accordingly.

Changes

Anonymous/none credential mode for S3

Layer / File(s) Summary
S3 config struct and credential mode constant
multi-storage-file-system/globals.go, multi-storage-file-system/csi/pkg/driver/node.go
Adds anonymous bool field to backendConfigS3Struct (default false) and credentialModeNone constant to the CSI driver credential-mode enum.
Config parsing and SIGHUP validation
multi-storage-file-system/config.go, multi-storage-file-system/config_test.go
Parses anonymous: true in S3 backend config and clears credential fields when set; SIGHUP validation enforces that anonymous cannot change on reload. New test validates the anonymous config path.
S3 SDK anonymous credentials wiring
multi-storage-file-system/backend_s3.go
setupS3Context installs aws.AnonymousCredentials when anonymous is true, converting the useCredentialsEnv branch to else if.
CSI driver: credential-mode resolution and msfs.yaml generation
multi-storage-file-system/csi/pkg/driver/node.go, multi-storage-file-system/csi/pkg/driver/node_test.go
resolveCredentialMode accepts "none"/"anonymous" aliases; writeConfig emits anonymous: true in S3 blocks for none mode; resolveWorkloadIdentity short-circuits for none mode. New tests cover all four none-mode behaviors.
Documentation
multi-storage-file-system/csi/README.md, multi-storage-file-system/csi/charts/msfs-csi/README.md, multi-storage-file-system/csi/charts/msfs-csi/values.yaml
Auth-mode tables, NodePublishVolume flow descriptions, and authType value comments extended to include none/anonymous.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • NVIDIA/multi-storage-client#84: Modifies the same node.go credential/config generation path for S3, extending per-workload IRSA token handling and buildEnv in the same areas this PR touches for none mode.

Suggested reviewers

  • shunjiad
  • edmc-ss

🐇 No keys, no sign, no secret line,
just anonymous: true and requests that shine!
The bunny hops through open fields so free,
unsigned requests for all the world to see.
No credentials needed — just connect and be! 🌿

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description has useful summary and test-plan content, but it does not follow the required Description/Checklist template or include the checklist items. Add the required ## Description and ## Checklist sections, and include the repo's development PR checklist item for .release_notes/.unreleased.md.
Docstring Coverage ⚠️ Warning Docstring coverage is 29.41% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed Clear and concise; it matches the new no-credentials anonymous mode, though it mentions CSI while the change also spans the core S3 backend.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat-msfs-csi-anonymous-auth

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.12.2)

level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies"


Comment @coderabbitai help to get the list of available commands.

@ankitmaster08 ankitmaster08 self-assigned this Jun 29, 2026
@ankitmaster08 ankitmaster08 requested a review from edmc-ss June 29, 2026 21:18

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@multi-storage-file-system/config.go`:
- Around line 1776-1783: The anonymous branch in the S3 config normalization
leaves useCredentialsEnv enabled even after clearing credentials, so update the
same backendConfigS3AsStruct handling to force useCredentialsEnv false whenever
anonymous is true. Make this change in the logic around
anonymous/useCredentialsEnv so setupS3Context and SIGHUP validation no longer
treat credential-env settings as active for anonymous mode.

In `@multi-storage-file-system/csi/pkg/driver/node_test.go`:
- Around line 193-215: Add a regression test in
TestWriteConfig_NoneModeAIStoreOmitsAnonymousAndCreds that populates
aisAuthnToken and aisAuthnTokenFile while using credentialModeNone, and assert
that writeConfig does not emit authn_token or authn_token_file for AIStore. Then
update writeConfig in node.go so the AIStore path skips both token fields when
authType is none, matching the none-mode contract and the existing
anonymous/token omission behavior in the test.

In `@multi-storage-file-system/csi/pkg/driver/node.go`:
- Around line 523-528: The credentialModeNone path still lets inherited
driver-pod AWS identity variables leak into the child process because buildEnv
returns os.Environ() unchanged. Update buildEnv to add an explicit none-mode
branch that strips AWS credential/IRSA-related environment variables before
returning, and use the existing credentialModeNone and buildEnv symbols to
locate the change.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: b0d95ca4-2992-4aa2-8a39-99a2942d79ee

📥 Commits

Reviewing files that changed from the base of the PR and between 499911b and 83ff892.

📒 Files selected for processing (9)
  • multi-storage-file-system/backend_s3.go
  • multi-storage-file-system/config.go
  • multi-storage-file-system/config_test.go
  • multi-storage-file-system/csi/README.md
  • multi-storage-file-system/csi/charts/msfs-csi/README.md
  • multi-storage-file-system/csi/charts/msfs-csi/values.yaml
  • multi-storage-file-system/csi/pkg/driver/node.go
  • multi-storage-file-system/csi/pkg/driver/node_test.go
  • multi-storage-file-system/globals.go

Comment on lines +1776 to +1783
if backendConfigS3AsStruct.anonymous {
// Anonymous access: no credentials are used (unsigned requests).
// Ignore any credentials file / access keys so a public or
// no-auth endpoint can be configured without them.
backendConfigS3AsStruct.credentialsFilePath = ""
backendConfigS3AsStruct.accessKeyID = ""
backendConfigS3AsStruct.secretAccessKey = ""
} else if backendConfigS3AsStruct.useCredentialsEnv {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Normalize useCredentialsEnv when anonymous is enabled.

This branch clears credential values, but leaves useCredentialsEnv true if the config set both flags. setupS3Context still observes that flag when adding shared-profile options, and SIGHUP validation can reject changes to a value that anonymous mode is supposed to ignore.

Proposed fix
 if backendConfigS3AsStruct.anonymous {
 	// Anonymous access: no credentials are used (unsigned requests).
 	// Ignore any credentials file / access keys so a public or
 	// no-auth endpoint can be configured without them.
+	backendConfigS3AsStruct.useCredentialsEnv = false
 	backendConfigS3AsStruct.credentialsFilePath = ""
 	backendConfigS3AsStruct.accessKeyID = ""
 	backendConfigS3AsStruct.secretAccessKey = ""
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if backendConfigS3AsStruct.anonymous {
// Anonymous access: no credentials are used (unsigned requests).
// Ignore any credentials file / access keys so a public or
// no-auth endpoint can be configured without them.
backendConfigS3AsStruct.credentialsFilePath = ""
backendConfigS3AsStruct.accessKeyID = ""
backendConfigS3AsStruct.secretAccessKey = ""
} else if backendConfigS3AsStruct.useCredentialsEnv {
if backendConfigS3AsStruct.anonymous {
// Anonymous access: no credentials are used (unsigned requests).
// Ignore any credentials file / access keys so a public or
// no-auth endpoint can be configured without them.
backendConfigS3AsStruct.useCredentialsEnv = false
backendConfigS3AsStruct.credentialsFilePath = ""
backendConfigS3AsStruct.accessKeyID = ""
backendConfigS3AsStruct.secretAccessKey = ""
} else if backendConfigS3AsStruct.useCredentialsEnv {
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@multi-storage-file-system/config.go` around lines 1776 - 1783, The anonymous
branch in the S3 config normalization leaves useCredentialsEnv enabled even
after clearing credentials, so update the same backendConfigS3AsStruct handling
to force useCredentialsEnv false whenever anonymous is true. Make this change in
the logic around anonymous/useCredentialsEnv so setupS3Context and SIGHUP
validation no longer treat credential-env settings as active for anonymous mode.

Comment on lines +193 to +215
func TestWriteConfig_NoneModeAIStoreOmitsAnonymousAndCreds(t *testing.T) {
ns := newNodeServer("node-test", "/usr/local/bin/msfs")
dir, configPath := writeConfigOrFatal(t, ns,
map[string]string{
"backendType": "AIStore",
"bucketName": "ais-bucket",
"aisEndpoint": "https://ais.example.com",
},
map[string]string{},
credentialModeNone,
)
defer os.RemoveAll(dir)

body := readFileOrFatal(t, configPath)
if !strings.Contains(body, "backend_type: AIStore") {
t.Fatalf("expected AIStore backend; got:\n%s", body)
}
// anonymous is an S3-only field; for AIStore, no-credentials means an empty
// token, so neither an anonymous flag nor a token should be emitted.
if strings.Contains(body, "anonymous:") || strings.Contains(body, "authn_token") {
t.Fatalf("none mode AIStore config must not emit anonymous/token; got:\n%s", body)
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Add a regression for AIStore token inputs in none mode.

This only tests the empty-attributes case. multi-storage-file-system/csi/pkg/driver/node.go:477-491 still writes authn_token / authn_token_file whenever those volume attributes are present, so authType=none can still send AIStore credentials even though the documented contract says the token is left empty. Please cover the case with aisAuthnToken and aisAuthnTokenFile populated, and update writeConfig to ignore them in none mode.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@multi-storage-file-system/csi/pkg/driver/node_test.go` around lines 193 -
215, Add a regression test in
TestWriteConfig_NoneModeAIStoreOmitsAnonymousAndCreds that populates
aisAuthnToken and aisAuthnTokenFile while using credentialModeNone, and assert
that writeConfig does not emit authn_token or authn_token_file for AIStore. Then
update writeConfig in node.go so the AIStore path skips both token fields when
authType is none, matching the none-mode contract and the existing
anonymous/token omission behavior in the test.

Comment on lines +523 to +528
// It returns ("", "", nil) when per-workload IRSA does not apply — static or
// no-credentials mode, a non-S3 backend, or no workload token in volume_context
// — so the caller keeps today's driver-SA behavior.
func (ns *nodeServer) resolveWorkloadIdentity(configDir string, volCtx map[string]string, mode credentialMode) (string, string, error) {
if mode == credentialModeStatic {
// Static and no-credentials mounts never use a projected workload token.
if mode == credentialModeStatic || mode == credentialModeNone {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

Strip inherited AWS identity vars in none mode.

credentialModeNone skips workload identity here, but buildEnv still returns os.Environ() unchanged, so driver-pod AWS_ROLE_ARN / AWS_WEB_IDENTITY_TOKEN_FILE can still reach the msfs child. Add an explicit none-mode branch in buildEnv that removes AWS credential/IRSA variables before returning.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@multi-storage-file-system/csi/pkg/driver/node.go` around lines 523 - 528, The
credentialModeNone path still lets inherited driver-pod AWS identity variables
leak into the child process because buildEnv returns os.Environ() unchanged.
Update buildEnv to add an explicit none-mode branch that strips AWS
credential/IRSA-related environment variables before returning, and use the
existing credentialModeNone and buildEnv symbols to locate the change.

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.

1 participant