From c5e8670b230d43e4d8216dd9116ba2b66efea5d3 Mon Sep 17 00:00:00 2001 From: Jim Rollenhagen Date: Fri, 25 Apr 2014 12:56:27 -0700 Subject: [PATCH] Remove Heartbeat-Before check from heartbeat Ironic does not send this header - agent should not look for it. Change-Id: I7b8857fa5f744bc03ee0907424a95b9305811c51 --- ironic_python_agent/ironic_api_client.py | 7 ---- .../tests/ironic_api_client.py | 32 ++----------------- 2 files changed, 2 insertions(+), 37 deletions(-) diff --git a/ironic_python_agent/ironic_api_client.py b/ironic_python_agent/ironic_api_client.py index 972bef714..04aba9c00 100644 --- a/ironic_python_agent/ironic_api_client.py +++ b/ironic_python_agent/ironic_api_client.py @@ -70,13 +70,6 @@ class APIClient(object): msg = 'Invalid status code: {0}'.format(response.status_code) raise errors.HeartbeatError(msg) - try: - return float(response.headers['Heartbeat-Before']) - except KeyError: - raise errors.HeartbeatError('Missing Heartbeat-Before header') - except Exception: - raise errors.HeartbeatError('Invalid Heartbeat-Before header') - def lookup_node(self, hardware_info, timeout, starting_interval): timer = backoff.BackOffLoopingCall( self._do_lookup, diff --git a/ironic_python_agent/tests/ironic_api_client.py b/ironic_python_agent/tests/ironic_api_client.py index 44d17137f..6799a4f19 100644 --- a/ironic_python_agent/tests/ironic_api_client.py +++ b/ironic_python_agent/tests/ironic_api_client.py @@ -13,7 +13,6 @@ # limitations under the License. import json -import time import mock from oslotest import base as test_base @@ -54,21 +53,16 @@ class TestBaseIronicPythonAgent(test_base.BaseTestCase): } def test_successful_heartbeat(self): - expected_heartbeat_before = time.time() + 120 - response = FakeResponse(status_code=202, headers={ - 'Heartbeat-Before': expected_heartbeat_before, - }) + response = FakeResponse(status_code=202) self.api_client.session.request = mock.Mock() self.api_client.session.request.return_value = response - heartbeat_before = self.api_client.heartbeat( + self.api_client.heartbeat( uuid='deadbeef-dabb-ad00-b105-f00d00bab10c', advertise_address=('192.0.2.1', '9999') ) - self.assertEqual(heartbeat_before, expected_heartbeat_before) - heartbeat_path = 'v1/nodes/deadbeef-dabb-ad00-b105-f00d00bab10c/' \ 'vendor_passthru/heartbeat' request_args = self.api_client.session.request.call_args[0] @@ -94,28 +88,6 @@ class TestBaseIronicPythonAgent(test_base.BaseTestCase): uuid='deadbeef-dabb-ad00-b105-f00d00bab10c', advertise_address=('192.0.2.1', '9999')) - def test_heartbeat_missing_heartbeat_before_header(self): - response = FakeResponse(status_code=202) - self.api_client.session.request = mock.Mock() - self.api_client.session.request.return_value = response - - self.assertRaises(errors.HeartbeatError, - self.api_client.heartbeat, - uuid='deadbeef-dabb-ad00-b105-f00d00bab10c', - advertise_address=('192.0.2.1', '9999')) - - def test_heartbeat_invalid_heartbeat_before_header(self): - response = FakeResponse(status_code=202, headers={ - 'Heartbeat-Before': 'tomorrow', - }) - self.api_client.session.request = mock.Mock() - self.api_client.session.request.return_value = response - - self.assertRaises(errors.HeartbeatError, - self.api_client.heartbeat, - uuid='deadbeef-dabb-ad00-b105-f00d00bab10c', - advertise_address=('192.0.2.1', '9999')) - @mock.patch('eventlet.greenthread.sleep') @mock.patch('ironic_python_agent.ironic_api_client.APIClient._do_lookup') def test_lookup_node(self, lookup_mock, sleep_mock):