Skip to content

Set default path for nsfs bucket OBC provisioning to the bucket name#1691

Merged
dannyzaken merged 1 commit intonoobaa:masterfrom
dannyzaken:danny-fixes
Aug 27, 2025
Merged

Set default path for nsfs bucket OBC provisioning to the bucket name#1691
dannyzaken merged 1 commit intonoobaa:masterfrom
dannyzaken:danny-fixes

Conversation

@dannyzaken
Copy link
Member

@dannyzaken dannyzaken commented Aug 27, 2025

Explain the changes

  1. 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.

Issues: Fixed #xxx / Gap #xxx

  1. https://issues.redhat.com/browse/DFBUGS-3817

Testing Instructions:

  • Doc added/updated
  • Tests added

Summary by CodeRabbit

  • Bug Fixes
    • Improved namespace bucket provisioning: if a NamespacePolicy is set and no path is provided, the system now defaults the path to the bucket name. This prevents failures caused by empty paths and ensures reliable bucket creation.
    • No impact to other bucket creation flows; behavior remains unchanged outside this scenario.
    • No user-facing configuration or API changes required; existing setups without a path will work as expected.

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>
@coderabbitai
Copy link

coderabbitai bot commented Aug 27, 2025

Walkthrough

Adjusts 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

Cohort / File(s) Change summary
Namespace bucket path defaulting
pkg/obc/provisioner.go
If NamespacePolicy exists and AdditionalConfig["path"] is empty, set path to BucketName before calling CreateNamespaceBucketInfoStructure; previously passed the possibly empty path directly.

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
Loading

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 Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

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

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@dannyzaken dannyzaken changed the title set default path for nsfs bucket OBC provisioning Set default path for nsfs bucket OBC provisioning to the bucket name Aug 27, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

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 path in 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 Policies

I dug into CreateNamespaceBucketInfoStructure and found that for both NSBucketClassTypeSingle and NSBucketClassTypeMulti, the passed-in path is 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 default path = r.BucketName will 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 that path remains 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.

📥 Commits

Reviewing files that changed from the base of the PR and between 35e2e61 and b64f204.

📒 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.

@dannyzaken dannyzaken merged commit aaf2d60 into noobaa:master Aug 27, 2025
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants