Skip to content

Commit 39fd414

Browse files
committed
Taint volume setting ID to nil in case of error
1 parent 85acada commit 39fd414

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

libvirt/resource_libvirt_volume.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,10 @@ func resourceLibvirtVolumeCreate(d *schema.ResourceData, meta interface{}) error
254254
if _, ok := d.GetOk("source"); ok {
255255
err = img.Import(newCopier(client.libvirt, volume, volumeDef.Capacity.Value), volumeDef)
256256
if err != nil {
257+
// don't save volume ID in case of error. This will taint the volume after.
258+
// If we don't throw away the id, we will keep instead a broken volume.
259+
// see for reference: https://github.com/dmacvicar/terraform-provider-libvirt/issues/494
260+
d.Set("id", "")
257261
return fmt.Errorf("Error while uploading source %s: %s", img.String(), err)
258262
}
259263
}

0 commit comments

Comments
 (0)