From c3f6bbcece0582b5056163b56ee78b97522572d8 Mon Sep 17 00:00:00 2001 From: Joe Topjian Date: Tue, 8 Dec 2015 05:47:34 +0000 Subject: [PATCH] provider/openstack: Handle volumes in "deleting" state This commit prevents Terraform from erroring when an attempt is made to delete a volume already in a "deleting" state. This can happen when the volume is the root disk of an instance and the instance was terminated. --- .../resource_openstack_blockstorage_volume_v1.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/builtin/providers/openstack/resource_openstack_blockstorage_volume_v1.go b/builtin/providers/openstack/resource_openstack_blockstorage_volume_v1.go index f8fde11ef..bbd65c731 100644 --- a/builtin/providers/openstack/resource_openstack_blockstorage_volume_v1.go +++ b/builtin/providers/openstack/resource_openstack_blockstorage_volume_v1.go @@ -259,9 +259,13 @@ func resourceBlockStorageVolumeV1Delete(d *schema.ResourceData, meta interface{} } } - err = volumes.Delete(blockStorageClient, d.Id()).ExtractErr() - if err != nil { - return fmt.Errorf("Error deleting OpenStack volume: %s", err) + // It's possible that this volume was used as a boot device and is currently + // in a "deleting" state from when the instance was terminated. + // If this is true, just move on. It'll eventually delete. + if v.Status != "deleting" { + if err := volumes.Delete(blockStorageClient, d.Id()).ExtractErr(); err != nil { + return CheckDeleted(d, err, "volume") + } } // Wait for the volume to delete before moving on.