Commit 442d31f6 authored by Sridutt Bhalachandra's avatar Sridutt Bhalachandra

[fix] Ensure that first N resources are always returned

Fixes NRM not returning the first N resources (cpu and memory). This
is important for reproducibility and reducing variation
parent 33316192
...@@ -28,11 +28,11 @@ class ResourceManager(object): ...@@ -28,11 +28,11 @@ class ResourceManager(object):
# - cpus are exclusive # - cpus are exclusive
# - memories exclusive if more than one left # - memories exclusive if more than one left
if len(self.available.cpus) >= request.cpus: if len(self.available.cpus) >= request.cpus:
retcpus = self.available.cpus[:request.cpus] retcpus = sorted(self.available.cpus)[:request.cpus]
else: else:
retcpus = [] retcpus = []
if len(self.available.mems) > 1: if len(self.available.mems) > 1:
retmems = self.available.mems[:request.mems] retmems = sorted(self.available.mems)[:request.mems]
else: else:
retmems = self.available.mems retmems = self.available.mems
ret = resources(retcpus, retmems) ret = resources(retcpus, retmems)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment