based on price cap. Don't add jobs to wishlist that exceed max price cap.
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)
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()
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
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')
{'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})