diff --git a/app/Services/DeploymentService.php b/app/Services/DeploymentService.php index 957b80495..ff2f16cbc 100644 --- a/app/Services/DeploymentService.php +++ b/app/Services/DeploymentService.php @@ -104,7 +104,12 @@ class DeploymentService */ public static function randomAllocation($node) { - return Models\Allocation::where('node', $node)->whereNull('assigned_to')->inRandomOrder()->first(); + $allocation = Models\Allocation::where('node', $node)->whereNull('assigned_to')->inRandomOrder()->first(); + if (!$allocation) { + throw new DisplayException('No available allocation could be found for the assigned node.'); + } + + return $allocation; } /**