@@ -123,9 +123,7 @@ def on_slave_heartbeat(self, hostname, now=datetime.utcnow()):
123
123
if self ._heart_beat_table [u_hostname ].state == HpcState .Provisioning :
124
124
with self ._table_lock :
125
125
if self ._heart_beat_table [u_hostname ].state == HpcState .Provisioning :
126
- self ._heart_beat_table [u_hostname ] = self ._heart_beat_table [u_hostname ]._replace (
127
- state = HpcState .Configuring )
128
- self .logger .info ("Configuring Host {}" .format (u_hostname ))
126
+ self ._set_nodes_configuring (u_hostname )
129
127
else :
130
128
self .logger .error ("Host {} is not recognized. Heartbeat ignored." .format (u_hostname ))
131
129
self .logger .debug ("_table {} " .format (self ._heart_beat_table ))
@@ -197,6 +195,7 @@ def _get_nodes_name_in_state(self, state):
197
195
# type: (HpcState) -> [str]
198
196
return [host .hostname for host in dict (self ._heart_beat_table ).itervalues () if host .state == state ]
199
197
198
+ # TODO: make state_machine methods more testable
200
199
def _configure_compute_nodes_state_machine (self ):
201
200
# type: () -> ()
202
201
configuring_node_names = self ._get_nodes_name_in_state (HpcState .Configuring )
@@ -229,11 +228,11 @@ def _configure_compute_nodes_state_machine(self):
229
228
invalid_state_node_dict = {}
230
229
for node_status in node_status_list :
231
230
node_name = _get_node_name_from_status (node_status )
232
- node_state = node_status [ HpcRestClient . NODE_STATUS_NODE_STATE_KEY ]
231
+ node_state = _get_node_state_from_status ( node_status )
233
232
if _check_node_health_unapproved (node_status ):
234
233
unapproved_node_list .append (node_name )
235
234
# node approved
236
- elif (self ._check_node_in_mesos_group (node_status ) or (
235
+ elif (not self ._check_node_in_mesos_group (node_status ) or (
237
236
self ._node_group_specified () and self ._check_node_in_specified_group (node_status ))):
238
237
if _check_node_state_online (node_status ):
239
238
take_offline_node_list .append (node_name )
@@ -372,6 +371,10 @@ def _set_nodes_running(self, node_names):
372
371
# type: (Iterable[str]) -> ()
373
372
self ._set_node_state (node_names , HpcState .Running , "Running" )
374
373
374
+ def _set_nodes_configuring (self , node_names ):
375
+ # type: (Iterable[str]) -> ()
376
+ self ._set_node_state (node_names , HpcState .Configuring , "Configuring" )
377
+
375
378
def _set_node_state (self , node_names , node_state , state_name ):
376
379
# type: (Iterable[str], int, str) -> [(str, int)]
377
380
set_nodes = []
@@ -478,7 +481,7 @@ def _close_node_state_machine(self, node_names):
478
481
479
482
def _check_node_in_mesos_group (self , node_status ):
480
483
# type: (dict[str, any]) -> bool
481
- return self .MESOS_NODE_GROUP_NAME .upper () not in _upper_strings (
484
+ return self .MESOS_NODE_GROUP_NAME .upper () in _upper_strings (
482
485
node_status [HpcRestClient .NODE_STATUS_NODE_GROUP_KEY ])
483
486
484
487
def _check_node_in_specified_group (self , node_status ):
0 commit comments