Skip to content

CLI support for backingstore endpoint update#2014

Open
karthikps97 wants to merge 1 commit into
noobaa:masterfrom
karthikps97:backingstore-cli
Open

CLI support for backingstore endpoint update#2014
karthikps97 wants to merge 1 commit into
noobaa:masterfrom
karthikps97:backingstore-cli

Conversation

@karthikps97

@karthikps97 karthikps97 commented Jul 9, 2026

Copy link
Copy Markdown
Member

Describe the Problem

Explain the changes

  1. Added backingstore update CLI command to update endpoint for select backing store types (IBM COS and S3 compatible)
  2. Refactored backing store type validation to use a centralized list.

Issues: Fixed #xxx / Gap #xxx

Testing Instructions:

  1. Create a backing store of type IBM COS or S3 compatible.
  2. Update the endpoint to a valid noobaa storage.
    nb backingstore update <name> --endpoint=<new-endpoint> -n <namespace>

Dependent PR's: PR 1, PR 2

  • Doc added/updated
  • Tests added

Summary by CodeRabbit

  • New Features
    • Added a backingstore update CLI subcommand with an --endpoint flag.
    • Endpoint updates are supported for specific backing store types.
  • Bug Fixes
    • Improved backing store type validation using a defined allowlist.
    • Prevent endpoint changes for unsupported store types and ensure updates are applied, then readiness is awaited and status is refreshed.

@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 9a33b02c-5f77-486a-919e-1904fdd75961

📥 Commits

Reviewing files that changed from the base of the PR and between 9bee92d and b09e359.

📒 Files selected for processing (1)
  • pkg/backingstore/backingstore.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • pkg/backingstore/backingstore.go

📝 Walkthrough

Walkthrough

Adds a new update subcommand to the backing store CLI. Introduces exported type constants and a validBackingStores allowlist, refactors RunCreate validation to use it, and implements RunUpdate to fetch a BackingStore CR, validate its type, update the endpoint for supported types, persist the change, and report status.

Changes

Backing store update support

Layer / File(s) Summary
Type constants and allowlist
pkg/backingstore/backingstore.go
Adds exported backing-store type constants (S3Compatible, IBMCOS, AWSS3, AWSSTSS3, GoogleCloudStorage, GoogleCloudStorageSTS, AzureBlob, AzureSTSBlob, PVPool), a validBackingStores allowlist, and the slices import.
RunCreate validation refactor
pkg/backingstore/backingstore.go
Replaces the explicit multi-branch string comparison in RunCreate with a slices.Contains(validBackingStores, ...) check.
Update subcommand and handler
pkg/backingstore/backingstore.go
Adds CmdUpdate() with an --endpoint flag registered in the command tree, and RunUpdate() which fetches the CR, validates type support, rejects unsupported endpoint updates, applies the endpoint, persists via util.KubeUpdate, waits for readiness, then runs RunStatus.

Estimated code review effort: 2 (Simple) | ~12 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant CLI as CmdUpdate/RunUpdate
  participant K8sAPI as Kubernetes API
  User->>CLI: noobaa backingstore update <name> --endpoint
  CLI->>K8sAPI: fetch BackingStore CR
  K8sAPI-->>CLI: return BackingStore
  CLI->>CLI: validate type against validBackingStores
  CLI->>CLI: apply endpoint to spec sub-structure
  CLI->>K8sAPI: KubeUpdate(BackingStore)
  K8sAPI-->>CLI: update confirmation
  CLI->>CLI: wait for readiness
  CLI->>User: RunStatus output
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: adding CLI support for backingstore endpoint updates.
Description check ✅ Passed The template is mostly filled in, but the problem statement and issue reference are left blank.
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 unit tests (beta)
  • Create PR with 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.

❤️ Share

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

Signed-off-by: Karthik P S <karthikperla2000@gmail.com>

@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: 1

🧹 Nitpick comments (1)
pkg/backingstore/backingstore.go (1)

35-49: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Reuse the shared backing-store type constants. Keep only the three STS-only strings local; the six common backing-store names can use nbv1.StoreType* to avoid drifting from the shared type values.

🤖 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 `@pkg/backingstore/backingstore.go` around lines 35 - 49, The backing-store
type constants in validBackingStores should reuse the shared nbv1.StoreType
values for the common non-STS names instead of duplicating local strings. Update
the constants in backingstore.go so only the three STS-only values remain local,
and change validBackingStores to reference nbv1.StoreTypeS3Compatible,
nbv1.StoreTypeIBMCOS, nbv1.StoreTypeAWSS3, nbv1.StoreTypeGoogleCloudStorage,
nbv1.StoreTypeAzureBlob, and nbv1.StoreTypePVPool alongside the local STS
constants.
🤖 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 `@pkg/backingstore/backingstore.go`:
- Around line 1016-1020: `RunUpdate` currently does nothing when `WaitReady(bs)`
returns false, so add an explicit failure or cancellation message in the
`RunUpdate` flow after the `WaitReady(bs)` check. Update the logging around the
existing `WaitReady(bs)` / `RunStatus(cmd, args)` path so users get clear
feedback for rejected or cancelled backing store readiness, using the existing
`RunUpdate` and `WaitReady` symbols to locate the branch.

---

Nitpick comments:
In `@pkg/backingstore/backingstore.go`:
- Around line 35-49: The backing-store type constants in validBackingStores
should reuse the shared nbv1.StoreType values for the common non-STS names
instead of duplicating local strings. Update the constants in backingstore.go so
only the three STS-only values remain local, and change validBackingStores to
reference nbv1.StoreTypeS3Compatible, nbv1.StoreTypeIBMCOS, nbv1.StoreTypeAWSS3,
nbv1.StoreTypeGoogleCloudStorage, nbv1.StoreTypeAzureBlob, and
nbv1.StoreTypePVPool alongside the local STS constants.
🪄 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: Pro

Run ID: 81a15727-6cdb-4bbd-b58d-d359dbe80a85

📥 Commits

Reviewing files that changed from the base of the PR and between cde9dbe and 9bee92d.

📒 Files selected for processing (1)
  • pkg/backingstore/backingstore.go

Comment on lines +1016 to +1020
if WaitReady(bs) {
log.Printf("")
log.Printf("")
RunStatus(cmd, args)
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Add user feedback when WaitReady returns false.

If WaitReady(bs) returns false (e.g., the backing store phase becomes Rejected or the context is cancelled), RunUpdate exits silently. The user sees "BackingStore Wait Ready:" with no subsequent indication of success or failure.

🔧 Proposed fix
 if WaitReady(bs) {
     log.Printf("")
     log.Printf("")
     RunStatus(cmd, args)
+} else {
+    log.Fatalf("❌ BackingStore %s did not become ready after update", bs.Name)
 }
📝 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 WaitReady(bs) {
log.Printf("")
log.Printf("")
RunStatus(cmd, args)
}
if WaitReady(bs) {
log.Printf("")
log.Printf("")
RunStatus(cmd, args)
} else {
log.Fatalf("❌ BackingStore %s did not become ready after update", bs.Name)
}
🤖 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 `@pkg/backingstore/backingstore.go` around lines 1016 - 1020, `RunUpdate`
currently does nothing when `WaitReady(bs)` returns false, so add an explicit
failure or cancellation message in the `RunUpdate` flow after the
`WaitReady(bs)` check. Update the logging around the existing `WaitReady(bs)` /
`RunStatus(cmd, args)` path so users get clear feedback for rejected or
cancelled backing store readiness, using the existing `RunUpdate` and
`WaitReady` symbols to locate the branch.

@karthikps97
karthikps97 requested a review from VershaAgrawal July 9, 2026 11:22

@shirady shirady left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

log.Fatalf(`❌ Invalid backing store spec`)
}
bs.Spec.IBMCos.Endpoint = endpoint
default:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think you can remove the default case, there is no code under it.

Short: "Update a backing store",
Run: RunUpdate,
}
cmd.Flags().String("endpoint", "", "New endpoint URL")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

To match the code style in the file, suggest writing it in multiple lines

Suggested change
cmd.Flags().String("endpoint", "", "New endpoint URL")
cmd.Flags().String(
"endpoint", "",
"New endpoint URL"
)

Comment on lines +962 to +963
// args: <backingstore name>
// flags: <endpoint>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't think you need this comment

Comment on lines +35 to +45
const (
S3Compatible = "s3-compatible"
IBMCOS = "ibm-cos"
AWSS3 = "aws-s3"
AWSSTSS3 = "aws-sts-s3"
GoogleCloudStorage = "google-cloud-storage"
GoogleCloudStorageSTS = "google-cloud-storage-sts"
AzureBlob = "azure-blob"
AzureSTSBlob = "azure-sts-blob"
PVPool = "pv-pool"
)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Someone might want to reuse this for namespacestore as well.

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.

2 participants