diff --git a/builtin/providers/openstack/resource_openstack_blockstorage_volume_v1.go b/builtin/providers/openstack/resource_openstack_blockstorage_volume_v1.go index 0479fbf55..b4d6b2031 100644 --- a/builtin/providers/openstack/resource_openstack_blockstorage_volume_v1.go +++ b/builtin/providers/openstack/resource_openstack_blockstorage_volume_v1.go @@ -130,9 +130,6 @@ func resourceBlockStorageVolumeV1Create(d *schema.ResourceData, meta interface{} } log.Printf("[INFO] Volume ID: %s", v.ID) - // Store the ID now - d.SetId(v.ID) - // Wait for the volume to become available. log.Printf( "[DEBUG] Waiting for volume (%s) to become available", @@ -154,6 +151,9 @@ func resourceBlockStorageVolumeV1Create(d *schema.ResourceData, meta interface{} v.ID, err) } + // Store the ID now + d.SetId(v.ID) + return resourceBlockStorageVolumeV1Read(d, meta) } @@ -314,6 +314,12 @@ func VolumeV1StateRefreshFunc(client *gophercloud.ServiceClient, volumeID string return nil, "", err } + if v.Status == "error" { + return v, v.Status, fmt.Errorf("There was an error creating the volume. " + + "Please check with your cloud admin or check the Block Storage " + + "API logs to see why this error occurred.") + } + return v, v.Status, nil } } diff --git a/builtin/providers/openstack/resource_openstack_blockstorage_volume_v2.go b/builtin/providers/openstack/resource_openstack_blockstorage_volume_v2.go index 82f96440e..3a889c301 100644 --- a/builtin/providers/openstack/resource_openstack_blockstorage_volume_v2.go +++ b/builtin/providers/openstack/resource_openstack_blockstorage_volume_v2.go @@ -142,9 +142,6 @@ func resourceBlockStorageVolumeV2Create(d *schema.ResourceData, meta interface{} } log.Printf("[INFO] Volume ID: %s", v.ID) - // Store the ID now - d.SetId(v.ID) - // Wait for the volume to become available. log.Printf( "[DEBUG] Waiting for volume (%s) to become available", @@ -166,6 +163,9 @@ func resourceBlockStorageVolumeV2Create(d *schema.ResourceData, meta interface{} v.ID, err) } + // Store the ID now + d.SetId(v.ID) + return resourceBlockStorageVolumeV2Read(d, meta) } @@ -325,6 +325,12 @@ func VolumeV2StateRefreshFunc(client *gophercloud.ServiceClient, volumeID string return nil, "", err } + if v.Status == "error" { + return v, v.Status, fmt.Errorf("There was an error creating the volume. " + + "Please check with your cloud admin or check the Block Storage " + + "API logs to see why this error occurred.") + } + return v, v.Status, nil } }