Skip to content

Commit b2cd7cc

Browse files
committed
Throw exception if no allocation is there.
1 parent 514512a commit b2cd7cc

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

app/Services/DeploymentService.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,12 @@ public static function smartRandomNode($memory, $disk, $location = null) {
104104
*/
105105
public static function randomAllocation($node)
106106
{
107-
return Models\Allocation::where('node', $node)->whereNull('assigned_to')->inRandomOrder()->first();
107+
$allocation = Models\Allocation::where('node', $node)->whereNull('assigned_to')->inRandomOrder()->first();
108+
if (!$allocation) {
109+
throw new DisplayException('No available allocation could be found for the assigned node.');
110+
}
111+
112+
return $allocation;
108113
}
109114

110115
/**

0 commit comments

Comments
 (0)