[cinder-csi-plugin] Validate volume status before attach#3129
Conversation
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.
|
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 Tip We noticed you've done this a few times! Consider joining the org to skip this step and gain Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions 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. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
What this PR does / why we need it:
AttachVolumenow validates that the volume is in an acceptable state before calling the Nova volume attach API.availableavailableorin-usePreviously, the driver would call
volumeattach.Createregardless 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 theMultiattachflag. This means: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
DetachVolumefunction already performs similar status validation (lines 307-318 ofopenstack_volumes.go), so this bringsAttachVolumeto parity.Release note: