Skip to content

Commit

Permalink
Merge pull request #13 from deNBI/development
Browse files Browse the repository at this point in the history
hot fix bug concerning calculation number of flavors.
  • Loading branch information
jkrue authored Oct 26, 2023
2 parents 2e35092 + 536596d commit bb79e85
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions openapi_server/denbi/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,11 @@ def __update_gpu_flavors__(self):
# add minimum of all resources needed to total number
total += min(t_gpu, t_vcpu, t_mem, t_disk)
# number of flavors possible with current available resources
c_gpu = int(0, (hypervisor["gpus"] - hypervisor["gpus_used"]) / int(gpu_count))
c_vcpu = int(0, (int(hypervisor["vcpus"]) * self.cpu_overprovisioning - int(
hypervisor["vcpus_used"])) / int(flavor["vcpus"]))
c_mem = int(0, int(hypervisor["memory_free"]) / int(flavor["ram"]))
c_disk = int(0, int(hypervisor["disk_available"] / local_disk))
if min(c_gpu, c_vcpu, c_mem, c_disk) < 0:
print(f"{c_gpu} {c_vcpu} {c_mem} {c_disk} {min(c_gpu, c_vcpu, c_mem, c_disk)}")
c_gpu = max(0,int((hypervisor["gpus"] - hypervisor["gpus_used"]) / int(gpu_count)))
c_vcpu = max(0,int((int(hypervisor["vcpus"]) * self.cpu_overprovisioning - int(
hypervisor["vcpus_used"])) / int(flavor["vcpus"])))
c_mem = max(0,int(int(hypervisor["memory_free"]) / int(flavor["ram"])))
c_disk = max(0,int(int(hypervisor["disk_available"] / local_disk)))
available += min(c_gpu, c_vcpu, c_mem, c_disk)

gpu_flavors.append(FlavorGPU(flavor_name=flavor["name"],
Expand Down

0 comments on commit bb79e85

Please sign in to comment.