From 71db701269dc5d2b5eb9239828a74e9c26cd7e66 Mon Sep 17 00:00:00 2001 From: Lucas Di Pentima Date: Tue, 12 Jun 2018 14:44:24 -0300 Subject: [PATCH] 7478: Moves invalid cloud size node's shutdown decision to proper method. Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima --- .../arvnodeman/computenode/dispatch/__init__.py | 10 +++++----- .../tests/test_computenode_dispatch.py | 15 +++++++++------ 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/services/nodemanager/arvnodeman/computenode/dispatch/__init__.py b/services/nodemanager/arvnodeman/computenode/dispatch/__init__.py index dec8ef1434..f7bb2cdbda 100644 --- a/services/nodemanager/arvnodeman/computenode/dispatch/__init__.py +++ b/services/nodemanager/arvnodeman/computenode/dispatch/__init__.py @@ -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'] diff --git a/services/nodemanager/tests/test_computenode_dispatch.py b/services/nodemanager/tests/test_computenode_dispatch.py index 28492650e5..778c9aeaf5 100644 --- a/services/nodemanager/tests/test_computenode_dispatch.py +++ b/services/nodemanager/tests/test_computenode_dispatch.py @@ -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) -- 2.30.2