diff --git a/ironic_python_agent/inspector.py b/ironic_python_agent/inspector.py index 9cfeb4e91..833592fe3 100644 --- a/ironic_python_agent/inspector.py +++ b/ironic_python_agent/inspector.py @@ -117,6 +117,7 @@ def inspect(): _RETRY_WAIT = 5 +_RETRY_WAIT_MAX = 30 _RETRY_ATTEMPTS = 5 @@ -138,7 +139,7 @@ def call_inspector(data, failures): requests.exceptions.HTTPError)), stop=tenacity.stop_after_attempt(_RETRY_ATTEMPTS), wait=tenacity.wait_exponential(multiplier=1.5, - min=_RETRY_WAIT, max=30), + min=_RETRY_WAIT, max=_RETRY_WAIT_MAX), reraise=True) def _post_to_inspector(): inspector_resp = requests.post( diff --git a/ironic_python_agent/tests/unit/test_inspector.py b/ironic_python_agent/tests/unit/test_inspector.py index cd5f2eae0..4143e938a 100644 --- a/ironic_python_agent/tests/unit/test_inspector.py +++ b/ironic_python_agent/tests/unit/test_inspector.py @@ -195,6 +195,7 @@ class TestCallInspector(base.IronicAgentTest): self.assertIsNone(res) @mock.patch.object(inspector, '_RETRY_WAIT', 0.01) + @mock.patch.object(inspector, '_RETRY_WAIT_MAX', 1) def test_inspector_retries(self, mock_post): mock_post.side_effect = requests.exceptions.ConnectionError failures = utils.AccumulatedFailures() @@ -205,6 +206,7 @@ class TestCallInspector(base.IronicAgentTest): self.assertEqual(5, mock_post.call_count) @mock.patch.object(inspector, '_RETRY_WAIT', 0.01) + @mock.patch.object(inspector, '_RETRY_WAIT_MAX', 1) @mock.patch.object(inspector, '_RETRY_ATTEMPTS', 3) def test_inspector_retries_on_50X_error(self, mock_post): mock_post.side_effect = [mock.Mock(status_code=500), @@ -218,6 +220,7 @@ class TestCallInspector(base.IronicAgentTest): self.assertEqual(3, mock_post.call_count) @mock.patch.object(inspector, '_RETRY_WAIT', 0.01) + @mock.patch.object(inspector, '_RETRY_WAIT_MAX', 1) @mock.patch.object(inspector, '_RETRY_ATTEMPTS', 2) def test_inspector_retry_on_50X_and_succeed(self, mock_post): mock_post.side_effect = [mock.Mock(status_code=503),