Skip to content

Commit

Permalink
Merge pull request #495 from MalloZup/no-mutex
Browse files Browse the repository at this point in the history
Remove mutex before poolRefresh
  • Loading branch information
dmacvicar authored Dec 9, 2018
2 parents 2ad0228 + 004f229 commit d5e60df
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 23 deletions.
3 changes: 0 additions & 3 deletions libvirt/cloudinit_def.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@ func (ci *defCloudInit) UploadIso(client *Client, iso string) (string, error) {
}
defer pool.Free()

client.poolMutexKV.Lock(ci.PoolName)
defer client.poolMutexKV.Unlock(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 {
Expand Down
10 changes: 4 additions & 6 deletions libvirt/config.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package libvirt

import (
"github.com/hashicorp/terraform/helper/mutexkv"
libvirt "github.com/libvirt/libvirt-go"
"log"

libvirt "github.com/libvirt/libvirt-go"
)

// Config struct for the libvirt-provider
Expand All @@ -13,8 +13,7 @@ type Config struct {

// Client libvirt
type Client struct {
libvirt *libvirt.Connect
poolMutexKV *mutexkv.MutexKV
libvirt *libvirt.Connect
}

// Client libvirt, generate libvirt client given URI
Expand All @@ -26,8 +25,7 @@ func (c *Config) Client() (*Client, error) {
log.Println("[INFO] Created libvirt client")

client := &Client{
libvirt: libvirtClient,
poolMutexKV: mutexkv.NewMutexKV(),
libvirt: libvirtClient,
}

return client, nil
Expand Down
3 changes: 0 additions & 3 deletions libvirt/coreos_ignition_def.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ func (ign *defIgnition) CreateAndUpload(client *Client) (string, error) {
}
defer pool.Free()

client.poolMutexKV.Lock(ign.PoolName)
defer client.poolMutexKV.Unlock(ign.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 {
Expand Down
3 changes: 0 additions & 3 deletions libvirt/resource_libvirt_volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,6 @@ func resourceLibvirtVolumeCreate(d *schema.ResourceData, meta interface{}) error
poolName = d.Get("pool").(string)
}

client.poolMutexKV.Lock(poolName)
defer client.poolMutexKV.Unlock(poolName)

pool, err := client.libvirt.LookupStoragePoolByName(poolName)
if err != nil {
return fmt.Errorf("can't find storage pool '%s'", poolName)
Expand Down
8 changes: 0 additions & 8 deletions libvirt/utils_volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,14 +294,6 @@ func removeVolume(client *Client, key string) error {
}
defer volPool.Free()

poolName, err := volPool.GetName()
if err != nil {
return fmt.Errorf("Error retrieving name of volume: %s", err)
}

client.poolMutexKV.Lock(poolName)
defer client.poolMutexKV.Unlock(poolName)

waitForSuccess("Error refreshing pool for volume", func() error {
return volPool.Refresh(0)
})
Expand Down

0 comments on commit d5e60df

Please sign in to comment.