Skip to content

fix: wait for volume to become available before cleanup deletion - #150

Merged
anurag5sh merged 1 commit into
hashicorp:mainfrom
Autherain:fix/wait-for-volume-before-cleanup
Jul 14, 2026
Merged

fix: wait for volume to become available before cleanup deletion#150
anurag5sh merged 1 commit into
hashicorp:mainfrom
Autherain:fix/wait-for-volume-before-cleanup

Conversation

@Autherain

Copy link
Copy Markdown
Contributor

Fixes #123

Problem

When use_blockstorage_volume is enabled, the Cleanup() method in StepCreateVolume` attempts to delete the volume immediately after the has been created. However, Cinder may still be detaching the (status "uploading"), causing deletion to fail with a 400 error:

  Volume status must be available or error or error_restoring or or error_managing and must not be migrating, belong to a group, have snapshots, awaiting a transfer, be disassociated from snapshots after volume transfer.

This leaves orphaned volumes that require manual cleanup.

Fix

Added a call to the existing WaitForVolume() function before attempting deletion in Cleanup(). This polls until the volume reaches "available" or "error" status, which is consistent with how Run() already waits after volume creation.

If the wait fails, deletion is still attempted as a best-effort
fallback.

Testing

  • go build ./... passes
  • go test ./builder/openstack/... passes
  • go fmt applied

@Autherain
Autherain requested a review from a team as a code owner March 31, 2026 16:13
@hashicorp-cla-app

hashicorp-cla-app Bot commented Mar 31, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@Autherain

Copy link
Copy Markdown
Contributor Author

Just a a friendly ping on this PR. It's been open since march 31 and has not been reviewed yet. It fixes a real issue we've been having around. Happy to make any changes needed !

@Autherain

Copy link
Copy Markdown
Contributor Author

@tanmay-hc I forgot to ping you ;)

@tanmay-hc

Copy link
Copy Markdown
Contributor

@anurag5sh Can you have a look?

Copilot AI 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.

Pull request overview

This PR addresses orphaned Cinder volumes when use_blockstorage_volume is enabled by ensuring the volume is in a deletable state before Cleanup() attempts deletion, aligning cleanup behavior with the existing post-create wait in Run().

Changes:

  • Add a pre-delete wait in StepCreateVolume.Cleanup() to wait for the volume to become available before attempting deletion.
  • Improve cleanup logging to report wait failures while still attempting deletion as best-effort.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread builder/openstack/step_create_volume.go
@anurag5sh
anurag5sh merged commit a8767e0 into hashicorp:main Jul 14, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unable to build image when using root block storage volume

4 participants