Set out some roach traps to catch all these 🐛

This commit is contained in:
Dane Everitt 2017-02-16 13:56:28 -05:00
parent 336234843d
commit 2e134b7a55
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
8 changed files with 24 additions and 25 deletions

View file

@ -65,7 +65,7 @@ class DeploymentService
throw new DisplayException('The location passed was not valid and could not be found.');
}
$node = Models\Node::where('location', $useLocation->id)->where('public', 1)->whereNotIn('id', $not)->inRandomOrder()->first();
$node = Models\Node::where('location_id', $useLocation->id)->where('public', 1)->whereNotIn('id', $not)->inRandomOrder()->first();
if (! $node) {
throw new DisplayException("Unable to find a node in location {$useLocation->short} (id: {$useLocation->id}) that is available and has space.");
}
@ -107,7 +107,7 @@ class DeploymentService
*/
public static function randomAllocation($node)
{
$allocation = Models\Allocation::where('node', $node)->whereNull('assigned_to')->inRandomOrder()->first();
$allocation = Models\Allocation::where('node_id', $node)->whereNull('server_id')->inRandomOrder()->first();
if (! $allocation) {
throw new DisplayException('No available allocation could be found for the assigned node.');
}
@ -125,7 +125,7 @@ class DeploymentService
protected static function checkNodeAllocation(Models\Node $node, $memory, $disk)
{
if (is_numeric($node->memory_overallocate) || is_numeric($node->disk_overallocate)) {
$totals = Models\Server::select(DB::raw('SUM(memory) as memory, SUM(disk) as disk'))->where('node', $node->id)->first();
$totals = Models\Server::select(DB::raw('SUM(memory) as memory, SUM(disk) as disk'))->where('node_id', $node->id)->first();
// Check memory limits
if (is_numeric($node->memory_overallocate)) {