resolve minor race conditions
This commit is contained in:
+4
-4
@@ -409,7 +409,7 @@ func (instance *Instance) Build() error {
|
|||||||
|
|
||||||
for volid := range instance.configDisks {
|
for volid := range instance.configDisks {
|
||||||
wg.Go(func() error {
|
wg.Go(func() error {
|
||||||
err = instance.BuildVolume(node, volid)
|
err := instance.BuildVolume(node, volid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("[ERR ] error rebuilding volume %s: %s", volid, err)
|
log.Printf("[ERR ] error rebuilding volume %s: %s", volid, err)
|
||||||
}
|
}
|
||||||
@@ -419,7 +419,7 @@ func (instance *Instance) Build() error {
|
|||||||
|
|
||||||
for netid := range instance.configNets {
|
for netid := range instance.configNets {
|
||||||
wg.Go(func() error {
|
wg.Go(func() error {
|
||||||
err = instance.BuildNet(node, netid)
|
err := instance.BuildNet(node, netid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("[ERR ] error rebuilding net %s: %s", netid, err)
|
log.Printf("[ERR ] error rebuilding net %s: %s", netid, err)
|
||||||
return err
|
return err
|
||||||
@@ -430,7 +430,7 @@ func (instance *Instance) Build() error {
|
|||||||
|
|
||||||
for deviceid := range instance.configHostPCIs {
|
for deviceid := range instance.configHostPCIs {
|
||||||
wg.Go(func() error {
|
wg.Go(func() error {
|
||||||
err = instance.BuildDevice(node, deviceid)
|
err := instance.BuildDevice(node, deviceid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("[ERR ] error rebuilding pci %s: %s", deviceid, err)
|
log.Printf("[ERR ] error rebuilding pci %s: %s", deviceid, err)
|
||||||
}
|
}
|
||||||
@@ -444,7 +444,7 @@ func (instance *Instance) Build() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if instance.Type == VM {
|
if instance.Type == VM {
|
||||||
err = instance.BuildBoot(node)
|
err := instance.BuildBoot(node)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("[ERR ] error rebuilding boot: %s", err)
|
log.Printf("[ERR ] error rebuilding boot: %s", err)
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -140,7 +140,9 @@ func (pve ProxmoxClient) Node(host *Node, nodeName string) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
host.storageLock.Lock()
|
||||||
host.storage[storage.Name] = content
|
host.storage[storage.Name] = content
|
||||||
|
host.storageLock.Unlock()
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
@@ -260,7 +262,10 @@ func GetVolumeInfo(host *Node, volume string) (*Volume, error) {
|
|||||||
volumeFile := volumeObj[""]
|
volumeFile := volumeObj[""]
|
||||||
volumeStorage := strings.Split(volumeFile, ":")[0]
|
volumeStorage := strings.Split(volumeFile, ":")[0]
|
||||||
|
|
||||||
|
host.storageLock.Lock()
|
||||||
storage, ok := host.storage[volumeStorage]
|
storage, ok := host.storage[volumeStorage]
|
||||||
|
host.storageLock.Unlock()
|
||||||
|
|
||||||
if !ok {
|
if !ok {
|
||||||
return &volumeData, fmt.Errorf("volume %s claims to be in storage %s but storage was not found", volume, volumeStorage)
|
return &volumeData, fmt.Errorf("volume %s claims to be in storage %s but storage was not found", volume, volumeStorage)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ type Node struct {
|
|||||||
InstancesLock sync.Mutex // lock for Instances map
|
InstancesLock sync.Mutex // lock for Instances map
|
||||||
Instances map[InstanceID]*Instance `json:"instances"`
|
Instances map[InstanceID]*Instance `json:"instances"`
|
||||||
pvenode *proxmox.Node
|
pvenode *proxmox.Node
|
||||||
|
storageLock sync.Mutex
|
||||||
storage map[string][]*proxmox.StorageContent
|
storage map[string][]*proxmox.StorageContent
|
||||||
cluster *Cluster
|
cluster *Cluster
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user