Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions builder/openstack/step_create_volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,17 @@ func (s *StepCreateVolume) Cleanup(state multistep.StateBag) {
return
}

ui.Say(fmt.Sprintf("Deleting volume: %s ...", s.volumeID))
// Wait for the volume to become available before deleting.
// After image creation from a volume, Cinder may still be detaching it
// (status "uploading"). Deleting in that state returns a 400 error.
ui.Say(fmt.Sprintf("Waiting for volume %s to become available...", s.volumeID))
if err := WaitForVolume(blockStorageClient, s.volumeID); err != nil {
ui.Error(fmt.Sprintf(
"Error waiting for volume %s to become available: %s. Attempting deletion anyway.",
s.volumeID, err))
}

// Delete the volume in any status if exists.
ui.Say(fmt.Sprintf("Deleting volume: %s ...", s.volumeID))
err = volumes.Delete(blockStorageClient, s.volumeID, volumes.DeleteOpts{}).ExtractErr()
if err != nil {
ui.Error(fmt.Sprintf(
Expand Down