resolve minor race conditions

This commit is contained in:
2026-07-10 21:29:51 +00:00
parent 027ed2dce6
commit f3defe4157
3 changed files with 10 additions and 4 deletions
+4 -4
View File
@@ -409,7 +409,7 @@ func (instance *Instance) Build() error {
for volid := range instance.configDisks {
wg.Go(func() error {
err = instance.BuildVolume(node, volid)
err := instance.BuildVolume(node, volid)
if err != nil {
log.Printf("[ERR ] error rebuilding volume %s: %s", volid, err)
}
@@ -419,7 +419,7 @@ func (instance *Instance) Build() error {
for netid := range instance.configNets {
wg.Go(func() error {
err = instance.BuildNet(node, netid)
err := instance.BuildNet(node, netid)
if err != nil {
log.Printf("[ERR ] error rebuilding net %s: %s", netid, err)
return err
@@ -430,7 +430,7 @@ func (instance *Instance) Build() error {
for deviceid := range instance.configHostPCIs {
wg.Go(func() error {
err = instance.BuildDevice(node, deviceid)
err := instance.BuildDevice(node, deviceid)
if err != nil {
log.Printf("[ERR ] error rebuilding pci %s: %s", deviceid, err)
}
@@ -444,7 +444,7 @@ func (instance *Instance) Build() error {
}
if instance.Type == VM {
err = instance.BuildBoot(node)
err := instance.BuildBoot(node)
if err != nil {
log.Printf("[ERR ] error rebuilding boot: %s", err)
return err
+5
View File
@@ -140,7 +140,9 @@ func (pve ProxmoxClient) Node(host *Node, nodeName string) error {
if err != nil {
return err
}
host.storageLock.Lock()
host.storage[storage.Name] = content
host.storageLock.Unlock()
}
return nil
})
@@ -260,7 +262,10 @@ func GetVolumeInfo(host *Node, volume string) (*Volume, error) {
volumeFile := volumeObj[""]
volumeStorage := strings.Split(volumeFile, ":")[0]
host.storageLock.Lock()
storage, ok := host.storage[volumeStorage]
host.storageLock.Unlock()
if !ok {
return &volumeData, fmt.Errorf("volume %s claims to be in storage %s but storage was not found", volume, volumeStorage)
}
+1
View File
@@ -29,6 +29,7 @@ type Node struct {
InstancesLock sync.Mutex // lock for Instances map
Instances map[InstanceID]*Instance `json:"instances"`
pvenode *proxmox.Node
storageLock sync.Mutex
storage map[string][]*proxmox.StorageContent
cluster *Cluster
}