7478: Moves invalid cloud size node's shutdown decision to proper method.
authorLucas Di Pentima <ldipentima@veritasgenetics.com>
Tue, 12 Jun 2018 17:44:24 +0000 (14:44 -0300)
committerLucas Di Pentima <ldipentima@veritasgenetics.com>
Tue, 12 Jun 2018 17:44:24 +0000 (14:44 -0300)
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <ldipentima@veritasgenetics.com>

services/nodemanager/arvnodeman/computenode/dispatch/__init__.py
services/nodemanager/tests/test_computenode_dispatch.py

index dec8ef1434c5f5ca08290ab71f0ecac765dc6ab9..f7bb2cdbda19776d87f32f93bf73d64f8c214867 100644 (file)
@@ -370,11 +370,6 @@ class ComputeNodeMonitorActor(config.actor_class):
     def get_state(self):
         """Get node state, one of ['unpaired', 'busy', 'idle', 'down']."""
 
-        # If this node's size is invalid (because it has a stale arvados_node_size
-        # tag), return 'down' so that it's properly shut down.
-        if self.cloud_node.size.id == 'invalid':
-            return 'down'
-
         # If this node is not associated with an Arvados node, return
         # 'unpaired' if we're in the boot grace period, and 'down' if not,
         # so it isn't counted towards usable nodes.
@@ -437,6 +432,11 @@ class ComputeNodeMonitorActor(config.actor_class):
         reason for the decision.
         """
 
+        # If this node's size is invalid (because it has a stale arvados_node_size
+        # tag), return True so that it's properly shut down.
+        if self.cloud_node.size.id == 'invalid':
+            return (True, "node's size tag '%s' not recognizable" % (self.cloud_node.extra['arvados_node_size'],))
+
         # Collect states and then consult state transition table whether we
         # should shut down.  Possible states are:
         # crunch_worker_state = ['unpaired', 'busy', 'idle', 'down']
index 28492650e5919cfd8bdc704bd7b5bdc953603990..778c9aeaf5ffdbbcecaf90ac8072ace7210ce4a5 100644 (file)
@@ -356,12 +356,6 @@ class ComputeNodeMonitorActorTestCase(testutil.ActorTestMixin,
     def node_state(self, *states):
         return self.node_actor.in_state(*states).get(self.TIMEOUT)
 
-    def test_in_state_when_invalid_cloud_node_size(self):
-        self.make_mocks(1)
-        self.cloud_mock.size.id = 'invalid'
-        self.make_actor()
-        self.assertTrue(self.node_state('down'))
-
     def test_in_state_when_unpaired(self):
         self.make_actor()
         self.assertTrue(self.node_state('unpaired'))
@@ -432,6 +426,15 @@ class ComputeNodeMonitorActorTestCase(testutil.ActorTestMixin,
         self.assertEquals(self.node_actor.shutdown_eligible().get(self.TIMEOUT),
                           (False, "node state is ('unpaired', 'open', 'boot wait', 'idle exceeded')"))
 
+    def test_shutdown_when_invalid_cloud_node_size(self):
+        self.make_mocks(1)
+        self.cloud_mock.size.id = 'invalid'
+        self.cloud_mock.extra['arvados_node_size'] = 'stale.type'
+        self.make_actor()
+        self.shutdowns._set_state(True, 600)
+        self.assertEquals((True, "node's size tag 'stale.type' not recognizable"),
+                          self.node_actor.shutdown_eligible().get(self.TIMEOUT))
+
     def test_shutdown_without_arvados_node(self):
         self.make_actor(start_time=0)
         self.shutdowns._set_state(True, 600)