]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
pybind/mirroring: advance state machine from stalled state
authorVenky Shankar <vshankar@redhat.com>
Thu, 29 Apr 2021 09:32:40 +0000 (05:32 -0400)
committerVenky Shankar <vshankar@redhat.com>
Thu, 27 May 2021 13:35:21 +0000 (09:35 -0400)
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 <vshankar@redhat.com>
(cherry picked from commit 626ddf5d93af84bb80d143e19eaed32b8023e4c1)

src/pybind/mgr/mirroring/fs/dir_map/policy.py

index 6e7058d929052fa6abccb8afcc52894ad4d506aa..608a92bf541bfaf014901eeb27813d5a19929f83 100644 (file)
@@ -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