summaryrefslogtreecommitdiff
path: root/libvirt/utils.go
diff options
context:
space:
mode:
authorFlavio Castelli <fcastelli@suse.com>2016-10-08 20:49:07 +0200
committerAlvaro <alvaro.saurin@gmail.com>2016-10-10 17:43:08 +0200
commit89e78f356db8ef86ffa4ec42d5fcb38c14555b32 (patch)
tree740663d3d93cf6e4a84c4e75bcf556a569123d7e /libvirt/utils.go
parent6073b90b233f89394ca907f6579d9103965b1db1 (diff)
downloadterraform-provider-libvirt-89e78f356db8ef86ffa4ec42d5fcb38c14555b32.tar
terraform-provider-libvirt-89e78f356db8ef86ffa4ec42d5fcb38c14555b32.tar.gz
Fix random issues when handling multiple cloudinit volumes
Sometimes the libvirt provider fails with cryptic messages when multiple cloudinit volumes are being used. libvirtd contains several messages like `internal error: pool has asynchronous jobs running`. This seems to be caused by invoking `pool.Refresh()` while a volume is being uploaded. This commit introduces a new structure that can be used to synchronize operations involving storage pools. From my testing this solves the issues we have experiences so far.
Diffstat (limited to 'libvirt/utils.go')
-rw-r--r--libvirt/utils.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/libvirt/utils.go b/libvirt/utils.go
index a4110904..0700b756 100644
--- a/libvirt/utils.go
+++ b/libvirt/utils.go
@@ -70,6 +70,14 @@ func RemoveVolume(virConn *libvirt.VirConnection, key string) error {
}
defer volPool.Free()
+ poolName, err := volPool.GetName()
+ if err != nil {
+ return fmt.Errorf("Error retrieving name of volume: %s", err)
+ }
+
+ PoolSync.AcquireLock(poolName)
+ defer PoolSync.ReleaseLock(poolName)
+
WaitForSuccess("Error refreshing pool for volume", func() error {
return volPool.Refresh(0)
})