summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDuncan Mac-Vicar P <dmacvicar@suse.de>2016-05-22 01:29:54 +0200
committerDuncan Mac-Vicar P <dmacvicar@suse.de>2016-05-22 01:29:54 +0200
commitb7f95464d5ab9df695414d976f026f262b8d246d (patch)
tree890f420caff966b0323e31a6691feefcda9039a3
parentc1ee126e821b1a13aca72e3380f3873f3bc1d9a0 (diff)
downloadterraform-provider-libvirt-b7f95464d5ab9df695414d976f026f262b8d246d.tar
terraform-provider-libvirt-b7f95464d5ab9df695414d976f026f262b8d246d.tar.gz
Another instance where pool refresh fails.
We retry blindly for success until timeout. Unfortunately we can't do the right thing because libvirt (for some reason) returns VIR_ERR_INTERNAL_ERROR instead of the expected VIR_ERR_RESOURCE_BUSY. Closes #16
-rw-r--r--libvirt/resource_libvirt_volume.go7
-rw-r--r--libvirt/utils.go2
2 files changed, 5 insertions, 4 deletions
diff --git a/libvirt/resource_libvirt_volume.go b/libvirt/resource_libvirt_volume.go
index ce4bb5ef..fb20196e 100644
--- a/libvirt/resource_libvirt_volume.go
+++ b/libvirt/resource_libvirt_volume.go
@@ -83,10 +83,9 @@ func resourceLibvirtVolumeCreate(d *schema.ResourceData, meta interface{}) error
// Refresh the pool of the volume so that libvirt knows it is
// not longer in use.
- err = pool.Refresh(0)
- if err != nil {
- return fmt.Errorf("Error refreshing pool for volume: %s", err)
- }
+ WaitForSuccess("Error refreshing pool for volume", func() error {
+ return pool.Refresh(0)
+ })
volumeDef := newDefVolume()
diff --git a/libvirt/utils.go b/libvirt/utils.go
index ffaa8ba6..ed645938 100644
--- a/libvirt/utils.go
+++ b/libvirt/utils.go
@@ -3,6 +3,7 @@ package libvirt
import (
"crypto/rand"
"fmt"
+ "log"
"time"
)
@@ -29,6 +30,7 @@ func WaitForSuccess(errorMessage string, f func() error) error {
if err == nil {
return nil
}
+ log.Printf("[DEBUG] %s. Re-trying.\n", err)
time.Sleep(1 * time.Second)
if time.Since(start) > 5*time.Minute {