Implement VM provision locking mechanism and enhance VM job handling
This commit is contained in:
@@ -6,6 +6,7 @@ use App\Enums\Order\OrderStatus;
|
||||
use App\Helpers\OrderHelper;
|
||||
use App\Jobs\Mail\Admin\AdminOrderNotificationJob;
|
||||
use App\Jobs\VirtualMachine\Create\CreateVirtualMachineJob;
|
||||
use App\Models\VmProvisionLock;
|
||||
use App\Models\Addon;
|
||||
use App\Models\Log as CustomerActivityLog;
|
||||
use App\Models\Order;
|
||||
@@ -224,6 +225,14 @@ class OrderService
|
||||
private function dispatchVmJob(Order $order, OrderItem $item, Service $service, $customer): void
|
||||
{
|
||||
try {
|
||||
if (VmProvisionLock::isRunning($customer->id)) {
|
||||
Log::warning('dispatchVmJob: blocked — customer already has a running VM provision', [
|
||||
'customer_id' => $customer->id,
|
||||
'order_item_id' => $item->id,
|
||||
]);
|
||||
return;
|
||||
}
|
||||
|
||||
dispatch(new CreateVirtualMachineJob($item));
|
||||
|
||||
Log::info('dispatchVmJob: CreateVirtualMachineJob dispatched', [
|
||||
|
||||
Reference in New Issue
Block a user