Skip to content

Commit

Permalink
Fix isViable for Nodes with "unlimited" resources (#559)
Browse files Browse the repository at this point in the history
  • Loading branch information
Boy132 authored Aug 22, 2024
1 parent 05477c7 commit 818781c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions app/Models/Node.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,21 +244,21 @@ public function allocations(): HasMany
*/
public function isViable(int $memory, int $disk, int $cpu): bool
{
if ($this->memory_overallocate >= 0) {
if ($this->memory > 0 && $this->memory_overallocate >= 0) {
$memoryLimit = $this->memory * (1 + ($this->memory_overallocate / 100));
if ($this->servers_sum_memory + $memory > $memoryLimit) {
return false;
}
}

if ($this->disk_overallocate >= 0) {
if ($this->disk > 0 && $this->disk_overallocate >= 0) {
$diskLimit = $this->disk * (1 + ($this->disk_overallocate / 100));
if ($this->servers_sum_disk + $disk > $diskLimit) {
return false;
}
}

if ($this->cpu_overallocate >= 0) {
if ($this->cpu > 0 && $this->cpu_overallocate >= 0) {
$cpuLimit = $this->cpu * (1 + ($this->cpu_overallocate / 100));
if ($this->servers_sum_cpu + $cpu > $cpuLimit) {
return false;
Expand Down

0 comments on commit 818781c

Please sign in to comment.