stalled = not self.execute_policy_action(dir_path, dir_state,
dir_state.transition.start_policy_action)
if stalled:
- dir_state.stalled = True
- log.debug(f'state machine stalled')
- return ActionType.NONE
+ next_action = ActionType.NONE
+ if dir_state.purging:
+ dir_state.next_state = None
+ dir_state.state = State.UNASSOCIATED
+ dir_state.transition = StateTransition.transit(State.DISASSOCIATING, ActionType.NONE)
+ self.set_state(dir_state, State.DISASSOCIATING)
+ next_action = dir_state.transition.action_type
+ else:
+ dir_state.stalled = True
+ log.debug(f'state machine stalled')
+ return next_action
return dir_state.transition.action_type
def finish_action(self, dir_path, r):
return False
log.debug(f'removing dir_state: {dir_state}')
dir_state.purging = True
- return self.set_state(dir_state, State.DISASSOCIATING)
+ # advance the state machine with DISASSOCIATING state for removal
+ if dir_state.stalled:
+ dir_state.state = State.UNASSOCIATED
+ dir_state.transition = StateTransition.transit(State.DISASSOCIATING, ActionType.NONE)
+ r = self.set_state(dir_state, State.DISASSOCIATING)
+ log.debug(f'dir_state: {dir_state}')
+ return r
def add_instances_initial(self, instance_ids):
"""Take care of figuring out instances which no longer exist