From: Adam King Date: Tue, 26 Oct 2021 12:30:11 +0000 (-0400) Subject: mgr/cephadm: new exception type for when agent's lock in use X-Git-Tag: v17.1.0~494^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=edbb900d39c82424ee6d1b6db5be8efbe2a4c794;p=ceph.git mgr/cephadm: new exception type for when agent's lock in use Signed-off-by: Adam King --- diff --git a/src/pybind/mgr/cephadm/agent.py b/src/pybind/mgr/cephadm/agent.py index cb5f9acdf05..1de205b71df 100644 --- a/src/pybind/mgr/cephadm/agent.py +++ b/src/pybind/mgr/cephadm/agent.py @@ -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}')