OSAC-3273, OSAC-4036: enforce Volume spec field immutability in Update - #319
Conversation
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: akshaynadkarni The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
@akshaynadkarni: This pull request references OSAC-3273 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the epic to target the "5.0.0" version, but no target version was set. This pull request references OSAC-4036 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the task to target the "5.0.0" version, but no target version was set. DetailsIn response to this:
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 openshift-eng/jira-lifecycle-plugin repository. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository: osac-project/coderabbit/.coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
WalkthroughPrivate volume updates now support protobuf field masks. The server retrieves the existing volume, merges requested changes, rejects modifications to immutable specification fields, and persists valid updates. Tests cover changed and unchanged specification values. ChangesPrivate volume update flow
Estimated code review effort: 3 (Moderate) | ~20 minutes Mergeability Score: ⚪ Minimal · up to The change adds server-side protection against modifying immutable Volume specification fields after creation, with focused and full-suite tests reported; no actionable merge-blocking risk remains beyond normal checks and review. Sequence Diagram(s)sequenceDiagram
participant Caller
participant PrivateVolumesServer
participant ExistingVolume
participant GenericUpdateOperation
Caller->>PrivateVolumesServer: Submit Update with object ID and field mask
PrivateVolumesServer->>ExistingVolume: Retrieve current volume
PrivateVolumesServer->>PrivateVolumesServer: Merge fields and validate immutable specification
PrivateVolumesServer->>GenericUpdateOperation: Persist validated update
GenericUpdateOperation-->>Caller: Return update result
Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 11✅ Passed checks (11 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
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. Comment |
|
🤖 Review · Commit: |
|
🤖 Finished Review · ✅ Success · Started 2:24 PM UTC · Completed 2:43 PM UTC Commit: |
ReviewFindingsMedium
Low
Previous runReviewFindingsMedium
Low
|
Volume spec fields (storage_tier, size_gib, access_mode) were mutable after creation via PATCH. The DB trigger on the volumes table only protects top-level columns; spec fields inside the JSONB data column had no protection. Adds server-side validation to PrivateVolumesServer.Update following the same pattern as PrivateBareMetalInstanceTypesServer: fetches the existing object, clones it, applies the field-masked update, then compares the merged spec against the original before delegating to generic.Update. Returns codes.InvalidArgument with a field-specific message if any immutable spec field changed. Unit tests cover rejection of changes to each of the three immutable fields, and verify that the stored value is unchanged after a rejected update. Status-only updates (state, vendor_volume_id, backend, protocol) are unaffected. Signed-off-by: akshaynadkarni <25892229+akshaynadkarni@users.noreply.github.com> Assisted-by: Claude Code <noreply@anthropic.com>
5ae7fbe to
18bf70a
Compare
|
🤖 Review · Commit: |
- Set merged spec back into request before generic.Update, matching the established pattern in PrivateBareMetalInstanceTypesServer - Extract cloneVolume helper consistent with other server cloneX helpers - Rename validateVolumeSpecImmutability to validateVolumeImmutability to match the naming pattern of other servers - Add inline step comments and Go doc comments on helpers - Add default case to applyVolumeUpdate switch - Add comment clarifying pvc_ref is intentionally mutable (set by CSI driver post-creation) - Add positive test confirming updates with unchanged spec values succeed Signed-off-by: akshaynadkarni <25892229+akshaynadkarni@users.noreply.github.com> Assisted-by: Claude Code <noreply@anthropic.com> Signed-off-by: akshaynadkarni <25892229+akshaynadkarni@users.noreply.github.com>
|
🤖 Finished Review · ✅ Success · Started 6:16 PM UTC · Completed 6:37 PM UTC Commit: |
|
/lgtm |
Summary
Fixes a bug (found during E2E testing, TC-A5) where Volume spec fields (
storage_tier,size_gib,access_mode) could be silently modified after creation via PATCH. Adds server-side immutability validation toPrivateVolumesServer.Update()following the same pattern used byPrivateBareMetalInstanceTypesServer. No operator or Helm changes.Why
The
volumestable has acheck_immutable_columnsDB trigger that protects top-level columns (id,name,tenant,project), but spec fields live inside thedataJSONB column which the trigger cannot inspect.Update()previously delegated directly togeneric.Update()with no validation, so any spec value could be overwritten.Spec fields are provisioned directly into the vendor CSI call: the storage tier selects the backend, the size and access mode are set on the PVC. Changing them after creation would produce a split-brain between what the fulfillment-service records and what the vendor actually provisioned.
Testing
Ticket
Feature: OSAC-2872 (Storage Control Plane)
Epic: OSAC-3273 (Volume API, Inventory & Storage Logic)
Task: OSAC-4036 (Enforce spec field immutability in Volume Update endpoint)
Signed-off-by: akshaynadkarni 25892229+akshaynadkarni@users.noreply.github.com
Assisted-by: Claude Code noreply@anthropic.com