add missing error handling

This commit is contained in:
2026-05-27 18:59:45 +00:00
parent dd54866c4e
commit 72ca7b8fc5
2 changed files with 42 additions and 15 deletions
+29 -9
View File
@@ -249,23 +249,39 @@ func (host *Node) RebuildInstance(instancetype InstanceType, vmid uint) error {
host.Instances[instanceID] = instance
for volid := range instance.configDisks {
instance.RebuildVolume(host, volid)
err = instance.RebuildVolume(host, volid)
if err != nil {
err_ch <- err
}
}
for netid := range instance.configNets {
instance.RebuildNet(host, netid)
err = instance.RebuildNet(host, netid)
if err != nil {
err_ch <- err
}
}
for deviceid := range instance.configHostPCIs {
instance.RebuildDevice(host, deviceid)
err = instance.RebuildDevice(host, deviceid)
if err != nil {
err_ch <- err
}
}
if instance.Type == VM {
instance.RebuildBoot(host)
err = instance.RebuildBoot(host)
if err != nil {
err_ch <- err
}
}
// after synchronizing an instance, resync pool membership
host.cluster.ResolvePoolMembership()
err = host.cluster.ResolvePoolMembership()
if err != nil {
err_ch <- err
}
err_ch <- nil
}()
@@ -302,11 +318,11 @@ func (instance *Instance) RebuildNet(host *Node, netid string) error {
return nil
}
func (instance *Instance) RebuildDevice(host *Node, deviceid string) {
func (instance *Instance) RebuildDevice(host *Node, deviceid string) error {
instanceDevice, ok := instance.configHostPCIs[deviceid]
if !ok { // if device does not exist
log.Printf("[WARN] %s not found in devices", deviceid)
return
log.Printf("[WARN] %s not found in devices on node %s", deviceid, host.Name)
return nil
}
hostDeviceBusID := DeviceID(strings.Split(instanceDevice, ",")[0])
@@ -322,9 +338,11 @@ func (instance *Instance) RebuildDevice(host *Node, deviceid string) {
}
instance.Devices[DeviceID(instanceDeviceBusID)].Device_ID = DeviceID(deviceid)
return nil
}
func (instance *Instance) RebuildBoot(host *Node) {
func (instance *Instance) RebuildBoot(host *Node) error {
instance.Boot = BootOrder{}
eligibleBoot := map[string]bool{}
@@ -365,4 +383,6 @@ func (instance *Instance) RebuildBoot(host *Node) {
log.Printf("[WARN] encountered disabled and non-eligible boot target %s in instance %s\n", bootTarget, instance.Name)
}
}
return nil
}