[ARVADOS] updated: 40f5397ed97f42ba231b63a057e9c9e834dac2a9
git at public.curoverse.com
git at public.curoverse.com
Fri Dec 4 15:22:17 EST 2015
Summary of changes:
.../arvnodeman/computenode/driver/gce.py | 14 +++++++---
.../tests/test_computenode_driver_gce.py | 30 ++++++++++++++++++++++
2 files changed, 41 insertions(+), 3 deletions(-)
via 40f5397ed97f42ba231b63a057e9c9e834dac2a9 (commit)
from ee9bfde99d0916cdc325d75fc480972d498d4c15 (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 40f5397ed97f42ba231b63a057e9c9e834dac2a9
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())
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list