feat: improve drive reattachment logic to safely remove unused entry after attaching volume
This commit is contained in:
@@ -1023,7 +1023,7 @@ class Storage extends Component
|
|||||||
|
|
||||||
$diskConfig = implode(',', $configParts);
|
$diskConfig = implode(',', $configParts);
|
||||||
|
|
||||||
// First, set the disk on the new bus
|
// First, set the disk on the new bus (this attaches the volume)
|
||||||
$proxmox->request(
|
$proxmox->request(
|
||||||
'/nodes/' . $this->server->node->name . '/qemu/' . $this->server->vm_id . '/config',
|
'/nodes/' . $this->server->node->name . '/qemu/' . $this->server->vm_id . '/config',
|
||||||
'put',
|
'put',
|
||||||
@@ -1032,14 +1032,19 @@ class Storage extends Component
|
|||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
// Then clear the unused slot (set to empty/none to remove the reference without deleting volume)
|
// Then remove the unused entry using delete parameter
|
||||||
$proxmox->request(
|
// This is safe because the volume is now attached to the new bus
|
||||||
'/nodes/' . $this->server->node->name . '/qemu/' . $this->server->vm_id . '/config',
|
try {
|
||||||
'put',
|
$proxmox->request(
|
||||||
[
|
'/nodes/' . $this->server->node->name . '/qemu/' . $this->server->vm_id . '/config',
|
||||||
$this->reattachingDriveKey => '',
|
'put',
|
||||||
]
|
[
|
||||||
);
|
'delete' => $this->reattachingDriveKey,
|
||||||
|
]
|
||||||
|
);
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
// Unused entry might already be cleaned up automatically, ignore this error
|
||||||
|
}
|
||||||
|
|
||||||
$this->notify("Drive reattached as {$targetKey} successfully.", 'success');
|
$this->notify("Drive reattached as {$targetKey} successfully.", 'success');
|
||||||
$this->closeReattachModal();
|
$this->closeReattachModal();
|
||||||
|
|||||||
Reference in New Issue
Block a user