diff options
author | Flavio Castelli <fcastelli@suse.com> | 2016-10-08 20:49:07 +0200 |
---|---|---|
committer | Alvaro <alvaro.saurin@gmail.com> | 2016-10-10 17:43:08 +0200 |
commit | 89e78f356db8ef86ffa4ec42d5fcb38c14555b32 (patch) | |
tree | 740663d3d93cf6e4a84c4e75bcf556a569123d7e /libvirt/cloudinit_def.go | |
parent | 6073b90b233f89394ca907f6579d9103965b1db1 (diff) | |
download | terraform-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/cloudinit_def.go')
-rw-r--r-- | libvirt/cloudinit_def.go | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/libvirt/cloudinit_def.go b/libvirt/cloudinit_def.go index da7e5f69..ea7c0dbe 100644 --- a/libvirt/cloudinit_def.go +++ b/libvirt/cloudinit_def.go @@ -58,6 +58,9 @@ func (ci *defCloudInit) CreateAndUpload(virConn *libvirt.VirConnection) (string, } defer pool.Free() + PoolSync.AcquireLock(ci.PoolName) + defer PoolSync.ReleaseLock(ci.PoolName) + // Refresh the pool of the volume so that libvirt knows it is // not longer in use. WaitForSuccess("Error refreshing pool for volume", func() error { @@ -161,7 +164,7 @@ func (ci *defCloudInit) createISO() (string, error) { if err = cmd.Run(); err != nil { return "", fmt.Errorf("Error while starting the creation of CloudInit's ISO image: %s", err) } - log.Print("ISO created at %s", isoDestination) + log.Printf("ISO created at %s", isoDestination) return isoDestination, nil } |