10383: Merge branch 'master' into 10383-arv-put-incremental-upload
[arvados.git] / services / nodemanager / arvnodeman / config.py
index f386653e98128b34d395222a2640fb20058718f8..b54461c47d81b9f87bc1096da254cdf60e3f8aa9 100644 (file)
@@ -4,9 +4,7 @@ from __future__ import absolute_import, print_function
 
 import ConfigParser
 import importlib
-import json
 import logging
-import ssl
 import sys
 
 import arvados
@@ -14,13 +12,15 @@ import httplib2
 import pykka
 from apiclient import errors as apierror
 
-# IOError is the base class for socket.error and friends.
+from .baseactor import BaseNodeManagerActor
+
+# 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,)
 
-actor_class = pykka.ThreadingActor
+actor_class = BaseNodeManagerActor
 
 class NodeManagerConfig(ConfigParser.SafeConfigParser):
     """Node Manager Configuration class.
@@ -42,8 +42,10 @@ 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)},
+                       'node_stale_after': str(60 * 60 * 2),
+                       'watchdog': '600'},
             'Logging': {'file': '/dev/stderr',
                         'level': 'WARNING'},
         }.iteritems():
@@ -99,13 +101,6 @@ class NodeManagerConfig(ConfigParser.SafeConfigParser):
         module = importlib.import_module('arvnodeman.computenode.driver.' +
                                          self.get('Cloud', 'provider'))
         auth_kwargs = self.get_section('Cloud Credentials')
-        # GCE credentials are delivered in a JSON file.
-        if 'json_credential_file' in auth_kwargs:
-            with open(auth_kwargs['json_credential_file']) as jf:
-                json_creds = json.load(jf)
-            auth_kwargs['user_id'] = json_creds['client_email']
-            auth_kwargs['key'] = json_creds['private_key']
-
         if 'timeout' in auth_kwargs:
             auth_kwargs['timeout'] = int(auth_kwargs['timeout'])
         return module.ComputeNodeDriver(auth_kwargs,
@@ -124,7 +119,10 @@ class NodeManagerConfig(ConfigParser.SafeConfigParser):
             sec_words = sec_name.split(None, 2)
             if sec_words[0] != 'Size':
                 continue
-            size_kwargs[sec_words[1]] = self.get_section(sec_name, int)
+            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: