[ARVADOS] updated: 4c5e5f9070e4e0fd9b07757c546b3bae48f2b664

git at public.curoverse.com git at public.curoverse.com
Wed Nov 18 09:25:36 EST 2015


Summary of changes:
 services/nodemanager/arvnodeman/daemon.py   | 10 ++++++----
 services/nodemanager/arvnodeman/jobqueue.py |  5 +++--
 services/nodemanager/arvnodeman/launcher.py |  3 ++-
 services/nodemanager/tests/test_jobqueue.py | 10 ++++++++++
 4 files changed, 21 insertions(+), 7 deletions(-)

       via  4c5e5f9070e4e0fd9b07757c546b3bae48f2b664 (commit)
      from  ba9ea75ee6d6322f5d2a9da0b1c01c2738c0927d (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit 4c5e5f9070e4e0fd9b07757c546b3bae48f2b664
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date:   Wed Nov 18 09:25:32 2015 -0500

    5353: Fix typo in _nodes_wanted().  Calculate number of nodes that can boot
    based on price cap.  Don't add jobs to wishlist that exceed max price cap.

diff --git a/services/nodemanager/arvnodeman/daemon.py b/services/nodemanager/arvnodeman/daemon.py
index 884567d..64bb177 100644
--- a/services/nodemanager/arvnodeman/daemon.py
+++ b/services/nodemanager/arvnodeman/daemon.py
@@ -272,12 +272,14 @@ class NodeManagerDaemonActor(actor_class):
                                            self._nodes_missing(size))
 
         wanted = self._size_wishlist(size) - up_count
-        if wanted > 0 and self.max_total_price and ((total_price + size.price) > self.max_total_price):
+        if wanted > 0 and self.max_total_price and ((total_price + (size.price*wanted)) > self.max_total_price):
+            can_boot = int((self.max_total_price - total_price) / size.price)
+            if can_boot == 0:
                 self._logger.info("Not booting %s (price %s) because with it would exceed max_total_price of %s (current total_price is %s)",
                                   size.name, size.price, self.max_total_price, total_price)
-                return 0
-
-        return
+            return can_boot
+        else:
+            return wanted
 
     def _nodes_excess(self, size):
         up_count = self._nodes_up(size) - self._size_shutdowns(size)
diff --git a/services/nodemanager/arvnodeman/jobqueue.py b/services/nodemanager/arvnodeman/jobqueue.py
index 06f66b7..8f78ba1 100644
--- a/services/nodemanager/arvnodeman/jobqueue.py
+++ b/services/nodemanager/arvnodeman/jobqueue.py
@@ -38,11 +38,12 @@ class ServerCalculator(object):
             return True
 
 
-    def __init__(self, server_list, max_nodes=None):
+    def __init__(self, server_list, max_nodes=None, max_price=None):
         self.cloud_sizes = [self.CloudSizeWrapper(s, **kws)
                             for s, kws in server_list]
         self.cloud_sizes.sort(key=lambda s: s.price)
         self.max_nodes = max_nodes or float('inf')
+        self.max_price = max_price or float('inf')
         self.logger = logging.getLogger('arvnodeman.jobqueue')
         self.logged_jobs = set()
 
@@ -75,7 +76,7 @@ class ServerCalculator(object):
                 if job['uuid'] not in self.logged_jobs:
                     self.logged_jobs.add(job['uuid'])
                     self.logger.debug("job %s not satisfiable", job['uuid'])
-            elif (want_count <= self.max_nodes):
+            elif (want_count <= self.max_nodes) and (want_count*cloud_size.price <= self.max_price):
                 servers.extend([cloud_size.real] * max(1, want_count))
         self.logged_jobs.intersection_update(seen_jobs)
         return servers
diff --git a/services/nodemanager/arvnodeman/launcher.py b/services/nodemanager/arvnodeman/launcher.py
index 592d217..e8c2fe6 100644
--- a/services/nodemanager/arvnodeman/launcher.py
+++ b/services/nodemanager/arvnodeman/launcher.py
@@ -62,7 +62,8 @@ def build_server_calculator(config):
     if not cloud_size_list:
         abort("No valid node sizes configured")
     return ServerCalculator(cloud_size_list,
-                            config.getint('Daemon', 'max_nodes'))
+                            config.getint('Daemon', 'max_nodes'),
+                            config.getfloat('Daemon', 'max_total_price'))
 
 def launch_pollers(config, server_calculator):
     poll_time = config.getint('Daemon', 'poll_time')
diff --git a/services/nodemanager/tests/test_jobqueue.py b/services/nodemanager/tests/test_jobqueue.py
index 2ddecd0..d4dc42f 100644
--- a/services/nodemanager/tests/test_jobqueue.py
+++ b/services/nodemanager/tests/test_jobqueue.py
@@ -48,6 +48,16 @@ class ServerCalculatorTestCase(unittest.TestCase):
                                   {'min_scratch_mb_per_node': 200})
         self.assertEqual(6, len(servlist))
 
+    def test_ignore_too_expensive_jobs(self):
+        servcalc = self.make_calculator([1, 2], max_nodes=12, max_price=6)
+        servlist = self.calculate(servcalc,
+                                  {'min_cores_per_node': 1, 'min_nodes': 6})
+        self.assertEqual(6, len(servlist))
+
+        servlist = self.calculate(servcalc,
+                                  {'min_cores_per_node': 2, 'min_nodes': 6})
+        self.assertEqual(0, len(servlist))
+
     def test_job_requesting_max_nodes_accepted(self):
         servcalc = self.make_calculator([1], max_nodes=4)
         servlist = self.calculate(servcalc, {'min_nodes': 4})

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list