[ARVADOS] updated: 765faab6cd2437a94ceec5b1685e639f72ef8627

git at public.curoverse.com git at public.curoverse.com
Fri Dec 4 16:46:42 EST 2015


Summary of changes:
 .../arvnodeman/computenode/driver/gce.py           | 14 +++++++---
 services/nodemanager/arvnodeman/config.py          | 10 +++++---
 .../tests/test_computenode_driver_gce.py           | 30 ++++++++++++++++++++++
 services/nodemanager/tests/test_config.py          |  2 ++
 4 files changed, 49 insertions(+), 7 deletions(-)

       via  765faab6cd2437a94ceec5b1685e639f72ef8627 (commit)
       via  2f0303982d8c3237a10a02bc5e578fae6f6b1f66 (commit)
       via  6f5021de4086494b0f693cf0d0aef28fd0a41bd5 (commit)
       via  e94f86dc97746ef21c641aadb56112481d1e66f5 (commit)
      from  dae3f71243933d142eb3c1e8d15e18e3764bfb2e (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 765faab6cd2437a94ceec5b1685e639f72ef8627
Merge: dae3f71 2f03039
Author: Brett Smith <brett at curoverse.com>
Date:   Fri Dec 4 16:46:38 2015 -0500

    Merge branch '7835-node-manager-price-type-wip'
    
    Refs #7835.  Closes #7950.


commit 2f0303982d8c3237a10a02bc5e578fae6f6b1f66
Author: Brett Smith <brett at curoverse.com>
Date:   Fri Dec 4 15:13:49 2015 -0500

    7835: Node Manager converts node.size into a size object on GCE.

diff --git a/services/nodemanager/arvnodeman/computenode/driver/gce.py b/services/nodemanager/arvnodeman/computenode/driver/gce.py
index 36bfc96..e461ed5 100644
--- a/services/nodemanager/arvnodeman/computenode/driver/gce.py
+++ b/services/nodemanager/arvnodeman/computenode/driver/gce.py
@@ -34,6 +34,7 @@ class ComputeNodeDriver(BaseComputeNodeDriver):
         super(ComputeNodeDriver, self).__init__(
             auth_kwargs, list_kwargs, create_kwargs,
             driver_class)
+        self._sizes_by_name = {sz.name: sz for sz in self.sizes.itervalues()}
         self._disktype_links = {dt.name: self._object_link(dt)
                                 for dt in self.real.ex_list_disktypes()}
 
@@ -103,9 +104,16 @@ class ComputeNodeDriver(BaseComputeNodeDriver):
     def list_nodes(self):
         # The GCE libcloud driver only supports filtering node lists by zone.
         # Do our own filtering based on tag list.
-        return [node for node in
-                super(ComputeNodeDriver, self).list_nodes()
-                if self.node_tags.issubset(node.extra.get('tags', []))]
+        nodelist = [node for node in
+                    super(ComputeNodeDriver, self).list_nodes()
+                    if self.node_tags.issubset(node.extra.get('tags', []))]
+        # As of 0.18, the libcloud GCE driver sets node.size to the size's name.
+        # It's supposed to be the actual size object.  Check that it's not,
+        # and monkeypatch the results when that's the case.
+        if nodelist and not hasattr(nodelist[0].size, 'id'):
+            for node in nodelist:
+                node.size = self._sizes_by_name[node.size]
+        return nodelist
 
     @classmethod
     def _find_metadata(cls, metadata_items, key):
diff --git a/services/nodemanager/tests/test_computenode_driver_gce.py b/services/nodemanager/tests/test_computenode_driver_gce.py
index b9d7ee9..41cb1aa 100644
--- a/services/nodemanager/tests/test_computenode_driver_gce.py
+++ b/services/nodemanager/tests/test_computenode_driver_gce.py
@@ -194,3 +194,33 @@ class GCEComputeNodeDriverTestCase(testutil.DriverTestMixin, unittest.TestCase):
         self.assertEqual(
             service_accounts,
             self.driver_mock().create_node.call_args[1]['ex_service_accounts'])
+
+    def test_fix_string_size(self):
+        # As of 0.18, the libcloud GCE driver sets node.size to the size's name.
+        # It's supposed to be the actual size object.  Make sure our driver
+        # patches that up in listings.
+        size = testutil.MockSize(2)
+        node = testutil.cloud_node_mock(size=size)
+        node.size = size.name
+        self.driver_mock().list_sizes.return_value = [size]
+        self.driver_mock().list_nodes.return_value = [node]
+        driver = self.new_driver()
+        nodelist = driver.list_nodes()
+        self.assertEqual(1, len(nodelist))
+        self.assertIs(node, nodelist[0])
+        self.assertIs(size, nodelist[0].size)
+
+    def test_skip_fix_when_size_not_string(self):
+        # Ensure we don't monkeypatch node sizes unless we need to.
+        size = testutil.MockSize(3)
+        node = testutil.cloud_node_mock(size=size)
+        self.driver_mock().list_nodes.return_value = [node]
+        driver = self.new_driver()
+        nodelist = driver.list_nodes()
+        self.assertEqual(1, len(nodelist))
+        self.assertIs(node, nodelist[0])
+        self.assertIs(size, nodelist[0].size)
+
+    def test_list_empty_nodes(self):
+        self.driver_mock().list_nodes.return_value = []
+        self.assertEqual([], self.new_driver().list_nodes())

commit 6f5021de4086494b0f693cf0d0aef28fd0a41bd5
Author: Brett Smith <brett at curoverse.com>
Date:   Fri Dec 4 14:37:06 2015 -0500

    Remove redundant exception from Node Manager NETWORK_ERRORS.

diff --git a/services/nodemanager/arvnodeman/config.py b/services/nodemanager/arvnodeman/config.py
index 50c3ceb..dd45165 100644
--- a/services/nodemanager/arvnodeman/config.py
+++ b/services/nodemanager/arvnodeman/config.py
@@ -5,7 +5,6 @@ from __future__ import absolute_import, print_function
 import ConfigParser
 import importlib
 import logging
-import ssl
 import sys
 
 import arvados
@@ -13,10 +12,10 @@ import httplib2
 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,)
 
 actor_class = pykka.ThreadingActor

commit e94f86dc97746ef21c641aadb56112481d1e66f5
Author: Brett Smith <brett at curoverse.com>
Date:   Fri Dec 4 14:35:30 2015 -0500

    7835: Node Manager coerces node size prices to float.

diff --git a/services/nodemanager/arvnodeman/config.py b/services/nodemanager/arvnodeman/config.py
index af9c8c0..50c3ceb 100644
--- a/services/nodemanager/arvnodeman/config.py
+++ b/services/nodemanager/arvnodeman/config.py
@@ -117,7 +117,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:
diff --git a/services/nodemanager/tests/test_config.py b/services/nodemanager/tests/test_config.py
index d43491e..e566928 100644
--- a/services/nodemanager/tests/test_config.py
+++ b/services/nodemanager/tests/test_config.py
@@ -24,6 +24,7 @@ creds = dummy_creds
 
 [Size 1]
 cores = 1
+price = 0.8
 
 [Logging]
 file = /dev/null
@@ -55,6 +56,7 @@ testlogger = INFO
         size, kwargs = sizes[0]
         self.assertEqual('Small', size.name)
         self.assertEqual(1, kwargs['cores'])
+        self.assertEqual(0.8, kwargs['price'])
 
     def test_shutdown_windows(self):
         config = self.load_config()

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list