Change to use WARNING level for heartbeat conflict errors
It's normal that ironic returns 409 Conflict from time to time, so it's a bit confusing that we report this with Exception level and traceback. Change-Id: I1627c61facc3fadd0f5d9d324150e7d2833c7fbc Closes-Bug: #1533113
This commit is contained in:
parent
9b9b982fdd
commit
d25d94b316
@ -118,6 +118,10 @@ class IronicPythonAgentHeartbeater(threading.Thread):
|
|||||||
)
|
)
|
||||||
self.error_delay = self.initial_delay
|
self.error_delay = self.initial_delay
|
||||||
LOG.info('heartbeat successful')
|
LOG.info('heartbeat successful')
|
||||||
|
except errors.HeartbeatConflictError:
|
||||||
|
LOG.warning('conflict error sending heartbeat')
|
||||||
|
self.error_delay = min(self.error_delay * self.backoff_factor,
|
||||||
|
self.max_delay)
|
||||||
except Exception:
|
except Exception:
|
||||||
LOG.exception('error sending heartbeat')
|
LOG.exception('error sending heartbeat')
|
||||||
self.error_delay = min(self.error_delay * self.backoff_factor,
|
self.error_delay = min(self.error_delay * self.backoff_factor,
|
||||||
|
@ -109,6 +109,15 @@ class HeartbeatError(IronicAPIError):
|
|||||||
super(HeartbeatError, self).__init__(details)
|
super(HeartbeatError, self).__init__(details)
|
||||||
|
|
||||||
|
|
||||||
|
class HeartbeatConflictError(IronicAPIError):
|
||||||
|
"""ConflictError raised when a heartbeat to the agent API fails."""
|
||||||
|
|
||||||
|
message = 'ConflictError heartbeating to agent API'
|
||||||
|
|
||||||
|
def __init__(self, details):
|
||||||
|
super(HeartbeatConflictError, self).__init__(details)
|
||||||
|
|
||||||
|
|
||||||
class LookupNodeError(IronicAPIError):
|
class LookupNodeError(IronicAPIError):
|
||||||
"""Error raised when the node lookup to the Ironic API fails."""
|
"""Error raised when the node lookup to the Ironic API fails."""
|
||||||
|
|
||||||
|
@ -72,7 +72,10 @@ class APIClient(object):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise errors.HeartbeatError(str(e))
|
raise errors.HeartbeatError(str(e))
|
||||||
|
|
||||||
if response.status_code != requests.codes.ACCEPTED:
|
if response.status_code == requests.codes.CONFLICT:
|
||||||
|
data = response.json
|
||||||
|
raise errors.HeartbeatConflictError(data.get('faultstring'))
|
||||||
|
elif response.status_code != requests.codes.ACCEPTED:
|
||||||
msg = 'Invalid status code: {0}'.format(response.status_code)
|
msg = 'Invalid status code: {0}'.format(response.status_code)
|
||||||
raise errors.HeartbeatError(msg)
|
raise errors.HeartbeatError(msg)
|
||||||
|
|
||||||
|
@ -89,6 +89,17 @@ class TestBaseIronicPythonAgent(test_base.BaseTestCase):
|
|||||||
uuid='deadbeef-dabb-ad00-b105-f00d00bab10c',
|
uuid='deadbeef-dabb-ad00-b105-f00d00bab10c',
|
||||||
advertise_address=('192.0.2.1', '9999'))
|
advertise_address=('192.0.2.1', '9999'))
|
||||||
|
|
||||||
|
def test_heartbeat_409_status_code(self):
|
||||||
|
response = mock.Mock()
|
||||||
|
response.status_code = 409
|
||||||
|
self.api_client.session.request = mock.Mock()
|
||||||
|
self.api_client.session.request.return_value = response
|
||||||
|
|
||||||
|
self.assertRaises(errors.HeartbeatConflictError,
|
||||||
|
self.api_client.heartbeat,
|
||||||
|
uuid='deadbeef-dabb-ad00-b105-f00d00bab10c',
|
||||||
|
advertise_address=('192.0.2.1', '9999'))
|
||||||
|
|
||||||
@mock.patch('eventlet.greenthread.sleep')
|
@mock.patch('eventlet.greenthread.sleep')
|
||||||
@mock.patch('ironic_python_agent.ironic_api_client.APIClient._do_lookup')
|
@mock.patch('ironic_python_agent.ironic_api_client.APIClient._do_lookup')
|
||||||
def test_lookup_node(self, lookup_mock, sleep_mock):
|
def test_lookup_node(self, lookup_mock, sleep_mock):
|
||||||
|
Loading…
Reference in New Issue
Block a user