Skip to content

Commit 295ffbe

Browse files
committed
Remove error when a volume exist already
It is wrong to error-out when a volume exist already. It can be that something failed and terraform apply a 2nd time should be ok (not fail) Consider use-case where people do terraform apply more times. In this way, this check doesn't make the terraform apply idempotent fix #613
1 parent f0630d1 commit 295ffbe

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

libvirt/resource_libvirt_volume.go

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -106,18 +106,12 @@ func resourceLibvirtVolumeCreate(d *schema.ResourceData, meta interface{}) error
106106
return pool.Refresh(0)
107107
})
108108

109-
// Check whether the storage volume already exists. Its name needs to be
110-
// unique.
111-
if _, err := pool.LookupStorageVolByName(d.Get("name").(string)); err == nil {
112-
return fmt.Errorf("storage volume '%s' already exists", d.Get("name").(string))
113-
}
114-
115109
volumeDef := newDefVolume()
116-
volumeDef.Name = d.Get("name").(string)
110+
if name, ok := d.GetOk("name"); ok {
111+
volumeDef.Name = name.(string)
112+
}
117113

118-
var (
119-
img image
120-
)
114+
var img image
121115

122116
givenFormat, isFormatGiven := d.GetOk("format")
123117
if isFormatGiven {

0 commit comments

Comments
 (0)