]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/cephadm: new exception type for when agent's lock in use
authorAdam King <adking@redhat.com>
Tue, 26 Oct 2021 12:30:11 +0000 (08:30 -0400)
committerAdam King <adking@redhat.com>
Tue, 26 Oct 2021 12:30:11 +0000 (08:30 -0400)
Signed-off-by: Adam King <adking@redhat.com>
src/pybind/mgr/cephadm/agent.py

index cb5f9acdf05eb1a928610ebaa2e5c9be5d3d0ca7..1de205b71df08d2efb334bc6d346e402fce4a06a 100644 (file)
@@ -302,6 +302,10 @@ class AgentMessageThread(threading.Thread):
         return
 
 
+class AgentLockException(Exception):
+    pass
+
+
 class CephadmAgentHelpers:
     def __init__(self, mgr: "CephadmOrchestrator"):
         self.mgr: "CephadmOrchestrator" = mgr
@@ -398,7 +402,7 @@ class CephadmAgentHelpers:
             self.mgr.agent_helpers.agent_locks[host] = threading.Lock()
         lock = self.mgr.agent_helpers.agent_locks[host]
         if not lock.acquire(False):
-            raise Exception('Agent lock in use')
+            raise AgentLockException()
         try:
             yield lock
         finally:
@@ -425,6 +429,9 @@ class CephadmAgentHelpers:
                     with self.mgr.agent_helpers.agent_lock(host):
                         daemon_spec = CephadmDaemonDeploySpec.from_daemon_description(agent)
                         self.mgr._daemon_action(daemon_spec, action='redeploy')
+                except AgentLockException:
+                    self.mgr.log.debug(
+                        f'Could not redeploy agent on host {host}. Someone else holds agent\'s lock')
                 except Exception as e:
                     self.mgr.log.debug(
                         f'Failed to redeploy agent on host {host}. Agent possibly never deployed: {e}')
@@ -448,6 +455,9 @@ class CephadmAgentHelpers:
                     with self.mgr.agent_helpers.agent_lock(host):
                         self.mgr._daemon_action(daemon_spec, action='reconfig')
                     return False
+            except AgentLockException:
+                self.mgr.log.debug(
+                    f'Could not reconfig agent on host {host}. Someone else holds agent\'s lock')
             except Exception as e:
                 self.mgr.log.debug(
                     f'Agent on host {host} not ready to have config and deps checked: {e}')
@@ -458,6 +468,9 @@ class CephadmAgentHelpers:
                         daemon_spec = CephadmDaemonDeploySpec.from_daemon_description(agent)
                         self.mgr._daemon_action(daemon_spec, action=action)
                         self.mgr.cache.rm_scheduled_daemon_action(agent.hostname, agent.name())
+                except AgentLockException:
+                    self.mgr.log.debug(
+                        f'Could not {action} agent on host {host}. Someone else holds agent\'s lock')
                 except Exception as e:
                     self.mgr.log.debug(
                         f'Agent on host {host} not ready to {action}: {e}')