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.
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']
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'))
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)