From: Venky Shankar Date: Thu, 29 Apr 2021 09:32:40 +0000 (-0400) Subject: pybind/mirroring: advance state machine from stalled state X-Git-Tag: v16.2.5~85^2~8 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=374cf17d6c590fcd045b0bdf1e8a25edc8d64003;p=ceph.git pybind/mirroring: advance state machine from stalled state Stalled state essentially pauses the state machine unitl there is atleast one active cephfs-mirror daemon available. A remove request at this point does not advance the state machine thereby resulting in the directory path never being untracked. So, advance the state machine when a directory path is removed in stalled state. Signed-off-by: Venky Shankar (cherry picked from commit 626ddf5d93af84bb80d143e19eaed32b8023e4c1) --- diff --git a/src/pybind/mgr/mirroring/fs/dir_map/policy.py b/src/pybind/mgr/mirroring/fs/dir_map/policy.py index 6e7058d9290..608a92bf541 100644 --- a/src/pybind/mgr/mirroring/fs/dir_map/policy.py +++ b/src/pybind/mgr/mirroring/fs/dir_map/policy.py @@ -180,9 +180,17 @@ class Policy: 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): @@ -244,7 +252,13 @@ class Policy: 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