Set default path for nsfs bucket OBC provisioning to the bucket name#1691
Set default path for nsfs bucket OBC provisioning to the bucket name#1691dannyzaken merged 1 commit intonoobaa:masterfrom
Conversation
When provisioning an NSFS bucket via OBC, use the bucket name as a default path in the nsfs_config. If "path" is set in `OBC.Spec.AdditionalConfig`, it should take precedence. Signed-off-by: Danny Zaken <dannyzaken@gmail.com>
WalkthroughAdjusts namespace bucket creation logic in pkg/obc/provisioner.go: when NamespacePolicy is present and OBC.AdditionalConfig["path"] is empty, the code now defaults the path to r.BucketName before creating NamespaceBucketInfo. No signatures or error handling paths changed. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant O as OBC
participant P as Provisioner
participant NB as NamespaceBucketInfoBuilder
Note over P: NamespacePolicy present
P->>P: path := O.AdditionalConfig["path"]
alt path is empty
P->>P: path = r.BucketName <<changed>>
else path provided
P->>P: use provided path
end
P->>NB: CreateNamespaceBucketInfoStructure(path, ...)
NB-->>P: NamespaceBucketInfo
P-->>O: Proceed with namespace bucket creation
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. ✨ Finishing Touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
Status, Documentation and Community
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (3)
pkg/obc/provisioner.go (3)
470-475: Normalize user-provided path; treat "/" and trailing slashes as empty.Edge case: users might pass "/" or "foo/". Normalizing avoids creating a root path or unexpected directories.
Apply this diff and add the import:
@@ - path := r.OBC.Spec.AdditionalConfig["path"] - if path == "" { - path = r.BucketName - } + // Normalize: trim leading/trailing slashes so "/" becomes empty and defaults to bucket name. + path := strings.Trim(r.OBC.Spec.AdditionalConfig["path"], "/") + if path == "" { + path = r.BucketName + } createBucketParams.Namespace = bucketclass.CreateNamespaceBucketInfoStructure(*r.BucketClass.Spec.NamespacePolicy, path)Add import:
import ( + "strings" )
470-475: Add a lightweight test to lock the default-path behavior.Recommend a unit test that provisions with NamespacePolicy and no
pathin AdditionalConfig, asserting the computed path passed into the namespace bucket info equals the bucket name. Mocking the NB client or factoring path selection into a small helper would make this trivial.I can refactor path selection into a small helper and add a focused test—want me to push that?
470-475: Confirm Path Is Applied for All Single/Multi Namespace PoliciesI dug into CreateNamespaceBucketInfoStructure and found that for both NSBucketClassTypeSingle and NSBucketClassTypeMulti, the passed-in
pathis always set on the WriteResource (even when the underlying namespace store is S3/Azure/GCP). Only Cache-type policies ignore it. In other words, your change to defaultpath = r.BucketNamewill now prefix every Single/Multi namespace bucket – regardless of backing‐store type – with the bucket name.Please review whether that global prefixing is intended for cloud‐backed buckets. If you meant to only default a filesystem mountpoint for NSFS, consider guarding the defaulting logic so it only applies when the namespace store is actually NSFS. For example:
• In pkg/obc/provisioner.go, wrap the defaulting in an NSFS check instead of always falling back to
r.BucketName.
• Or add a conditional around CreateNamespaceBucketInfoStructure so thatpathremains empty for non-NSFS bucketclasses.Let me know if you’d like suggestions on implementing the gating.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
pkg/obc/provisioner.go(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (13)
- GitHub Check: run-kms-tls-token-test
- GitHub Check: run-core-config-map-tests
- GitHub Check: run-hac-test
- GitHub Check: cnpg-deployment-test
- GitHub Check: run-kms-kmip-test
- GitHub Check: run-kms-tls-sa-test
- GitHub Check: run-admission-test
- GitHub Check: run-azure-vault-test
- GitHub Check: run-kms-key-rotate-test
- GitHub Check: run-operator-tests
- GitHub Check: run-kms-dev-test
- GitHub Check: run-cli-tests
- GitHub Check: golangci-lint
🔇 Additional comments (1)
pkg/obc/provisioner.go (1)
470-475: Sensible default for NSFS path; respects explicit OBC path.Using the bucket name as a fallback when no "path" is supplied aligns with the PR objective and keeps behavior explicit while preserving user-provided overrides.
Explain the changes
OBC.Spec.AdditionalConfig, it should take precedence.Issues: Fixed #xxx / Gap #xxx
Testing Instructions:
Summary by CodeRabbit