summaryrefslogtreecommitdiff
path: root/ironic/drivers/modules/agent_client.py
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2020-03-27 13:48:37 +0000
committerGerrit Code Review <review@openstack.org>2020-03-27 13:48:37 +0000
commit5e9aabf521cf6f78fa84183eaa52be744149e085 (patch)
tree100ffee7d9dd8c6a311984ff142c40380b3bbcb6 /ironic/drivers/modules/agent_client.py
parentec42ca77a1ad242ac9738c888c1dcdc2bb6cb2fc (diff)
parent242775ae184582ce51a006e5797e7017133617f3 (diff)
downloadironic-5e9aabf521cf6f78fa84183eaa52be744149e085.tar.gz
Merge "Retry agent get_command_status upon failures"
Diffstat (limited to 'ironic/drivers/modules/agent_client.py')
-rw-r--r--ironic/drivers/modules/agent_client.py15
1 files changed, 14 insertions, 1 deletions
diff --git a/ironic/drivers/modules/agent_client.py b/ironic/drivers/modules/agent_client.py
index cd3a91ef1..ee437ea6f 100644
--- a/ironic/drivers/modules/agent_client.py
+++ b/ironic/drivers/modules/agent_client.py
@@ -137,6 +137,10 @@ class AgentClient(object):
return result
@METRICS.timer('AgentClient.get_commands_status')
+ @retrying.retry(
+ retry_on_exception=(
+ lambda e: isinstance(e, exception.AgentConnectionFailed)),
+ stop_max_attempt_number=CONF.agent.max_command_attempts)
def get_commands_status(self, node):
"""Get command status from agent.
@@ -166,7 +170,16 @@ class AgentClient(object):
"""
url = self._get_command_url(node)
LOG.debug('Fetching status of agent commands for node %s', node.uuid)
- resp = self.session.get(url, timeout=CONF.agent.command_timeout)
+ try:
+ resp = self.session.get(url, timeout=CONF.agent.command_timeout)
+ except (requests.ConnectionError, requests.Timeout) as e:
+ msg = (_('Failed to connect to the agent running on node %(node)s '
+ 'to collect commands status. '
+ 'Error: %(error)s') %
+ {'node': node.uuid, 'error': e})
+ LOG.error(msg)
+ raise exception.AgentConnectionFailed(reason=msg)
+
result = resp.json()['commands']
status = '; '.join('%(cmd)s: result "%(res)s", error "%(err)s"' %
{'cmd': r.get('command_name'),