X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/6f31d0c9d4b6a0d3070e933a84cfd843722e81b1..48369a1e78683cec26b7154d5edc5f3450fec245:/services/nodemanager/arvnodeman/config.py diff --git a/services/nodemanager/arvnodeman/config.py b/services/nodemanager/arvnodeman/config.py index 079e623c55..dd45165dea 100644 --- a/services/nodemanager/arvnodeman/config.py +++ b/services/nodemanager/arvnodeman/config.py @@ -5,20 +5,18 @@ from __future__ import absolute_import, print_function import ConfigParser import importlib import logging -import ssl +import sys import arvados import httplib2 -import libcloud.common.types as cloud_types import pykka from apiclient import errors as apierror -# IOError is the base class for socket.error and friends. +# IOError is the base class for socket.error, ssl.SSLError, and friends. # It seems like it hits the sweet spot for operations we want to retry: # it's low-level, but unlikely to catch code bugs. -NETWORK_ERRORS = (IOError, ssl.SSLError) +NETWORK_ERRORS = (IOError,) ARVADOS_ERRORS = NETWORK_ERRORS + (apierror.Error,) -CLOUD_ERRORS = NETWORK_ERRORS + (cloud_types.LibcloudError,) actor_class = pykka.ThreadingActor @@ -42,6 +40,8 @@ class NodeManagerConfig(ConfigParser.SafeConfigParser): 'poll_time': '60', 'max_poll_time': '300', 'poll_stale_after': '600', + 'max_total_price': '0', + 'boot_fail_after': str(sys.maxint), 'node_stale_after': str(60 * 60 * 2)}, 'Logging': {'file': '/dev/stderr', 'level': 'WARNING'}, @@ -88,8 +88,7 @@ class NodeManagerConfig(ConfigParser.SafeConfigParser): http = httplib2.Http(timeout=self.getint('Arvados', 'timeout'), ca_certs=certs_file, disable_ssl_certificate_validation=insecure) - return arvados.api('v1', - cache=False, # Don't reuse an existing client. + return arvados.api(version='v1', host=self.get('Arvados', 'host'), token=self.get('Arvados', 'token'), insecure=insecure, @@ -106,14 +105,29 @@ class NodeManagerConfig(ConfigParser.SafeConfigParser): self.get_section('Cloud Create')) def node_sizes(self, all_sizes): + """Finds all acceptable NodeSizes for our installation. + + Returns a list of (NodeSize, kwargs) pairs for each NodeSize object + returned by libcloud that matches a size listed in our config file. + """ + size_kwargs = {} for sec_name in self.sections(): sec_words = sec_name.split(None, 2) if sec_words[0] != 'Size': continue - size_kwargs[sec_words[1]] = self.get_section(sec_name, int) - return [(size, size_kwargs[size.id]) for size in all_sizes - if size.id in size_kwargs] + size_spec = self.get_section(sec_name, int) + if 'price' in size_spec: + size_spec['price'] = float(size_spec['price']) + size_kwargs[sec_words[1]] = size_spec + # EC2 node sizes are identified by id. GCE sizes are identified by name. + matching_sizes = [] + for size in all_sizes: + if size.id in size_kwargs: + matching_sizes.append((size, size_kwargs[size.id])) + elif size.name in size_kwargs: + matching_sizes.append((size, size_kwargs[size.name])) + return matching_sizes def shutdown_windows(self): return [int(n)