Skip to content

[cinder-csi-plugin] Validate volume status before attach#3129

Open
hemna wants to merge 1 commit into
kubernetes:masterfrom
hemna:csi/validate-volume-status-before-attach
Open

[cinder-csi-plugin] Validate volume status before attach#3129
hemna wants to merge 1 commit into
kubernetes:masterfrom
hemna:csi/validate-volume-status-before-attach

Conversation

@hemna

@hemna hemna commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

What this PR does / why we need it:

AttachVolume now validates that the volume is in an acceptable state before calling the Nova volume attach API.

  • For regular (single-attach) volumes: status must be available
  • For multi-attach capable volumes: status must be available or in-use

Previously, the driver would call volumeattach.Create regardless of volume status, relying on Nova/Cinder to reject the request. This produced opaque 409 Conflict errors that made troubleshooting difficult and generated unnecessary API calls for volumes in transitional states (e.g., creating, downloading, detaching).

With this change the driver returns an immediate, descriptive error when the volume is not attachable, allowing the CO (external-attacher) to retry with exponential backoff via standard CSI error handling.

How it works:

The check is placed inside AttachVolume (after the existing idempotency check for already-attached volumes), which already fetches the volume to inspect attachments and the Multiattach flag. This means:

  • No additional API calls are introduced
  • No new interface methods are required
  • No changes to mock/fakecloud implementations are needed

Which issue this PR fixes (if applicable):
Related to #3124

Special notes for reviewers:

This is a simpler alternative to the polling/waiting approach in #3124. Rather than adding a wait-loop with poll intervals and context deadline handling, this PR fails fast with a clear error and lets the CO handle retries — which it already does via exponential backoff.

The DetachVolume function already performs similar status validation (lines 307-318 of openstack_volumes.go), so this brings AttachVolume to parity.

Release note:

[cinder-csi-plugin] AttachVolume now validates volume status before calling the Nova attach API, returning clear errors for volumes not in an attachable state.

Check that a volume is in an acceptable state before calling the Nova
attach API. For regular volumes the status must be 'available'. For
multi-attach capable volumes, both 'available' and 'in-use' are valid.

Previously the driver would blindly call volumeattach.Create regardless
of volume status, relying on Nova/Cinder to reject the request. This
produced opaque errors that made troubleshooting difficult and generated
unnecessary API calls for volumes in transitional states (creating,
downloading, detaching, etc.).

With this change the driver returns an immediate, descriptive error when
the volume is not attachable, allowing the CO (external-attacher) to
retry with exponential backoff via standard CSI error handling.
@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jun 15, 2026
@k8s-ci-robot

Copy link
Copy Markdown
Contributor

Hi @hemna. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Tip

We noticed you've done this a few times! Consider joining the org to skip this step and gain /lgtm and other bot rights. We recommend asking approvers on your previous PRs to sponsor you.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

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 kubernetes-sigs/prow repository.

@k8s-ci-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign kayrus for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot requested review from kayrus and zetaab June 15, 2026 17:16
@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jun 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants