Implement VM provision locking mechanism and enhance VM job handling

This commit is contained in:
baodev0
2026-07-13 11:23:53 +07:00
parent 0976e23d1a
commit 8d3410f8cc
11 changed files with 143 additions and 131 deletions
@@ -24,7 +24,9 @@ class VmIpReservationService
public function reserve(int $networkId, int $hostId, string $dns): ?array
{
return DB::transaction(function () use ($networkId, $hostId, $dns) {
// ponytail: exclude only IPs with an actual VM assigned, not stale __pending__ reservations
$usedIps = ModuleIpAddress::where('module_network_id', $networkId)
->where('vm_name', '!=', '__pending__')
->lockForUpdate()
->pluck('ip')
->toArray();