Browse Source

Merge "Extend retries to 9, 10 seconds apart."

tags/6.2.0
Zuul 1 week ago
committed by Gerrit Code Review
parent
commit
9219aae291
3 changed files with 16 additions and 4 deletions
  1. +2
    -2
      ironic_python_agent/config.py
  2. +6
    -2
      ironic_python_agent/tests/unit/extensions/test_standby.py
  3. +8
    -0
      releasenotes/notes/extend-retry-timeout-30c930a33d97c193.yaml

+ 2
- 2
ironic_python_agent/config.py View File

@@ -245,12 +245,12 @@ cli_opts = [
help='The connection timeout (in seconds) when downloading '
'an image. Does not affect the whole download.'),
cfg.IntOpt('image_download_connection_retries', min=0,
default=APARAMS.get('ipa-image-download-connection-retries', 2),
default=APARAMS.get('ipa-image-download-connection-retries', 9),
help='How many times to retry the connection when downloading '
'an image. Also retries on failure HTTP statuses.'),
cfg.IntOpt('image_download_connection_retry_interval', min=0,
default=APARAMS.get(
'ipa-image-download-connection-retry-interval', 5),
'ipa-image-download-connection-retry-interval', 10),
help='Interval (in seconds) between two attempts to establish '
'connection when downloading an image.'),



+ 6
- 2
ironic_python_agent/tests/unit/extensions/test_standby.py View File

@@ -412,6 +412,7 @@ class TestStandbyExtension(base.IronicAgentTest):

@mock.patch('requests.get', autospec=True)
def test_download_image_bad_status(self, requests_mock):
self.config(image_download_connection_retry_interval=0)
image_info = _build_fake_image_info()
response = requests_mock.return_value
response.status_code = 404
@@ -1243,6 +1244,7 @@ class TestStandbyExtension(base.IronicAgentTest):
return self

self.config(image_download_connection_timeout=1)
self.config(image_download_connection_retries=2)
self.config(image_download_connection_retry_interval=0)
image_info = _build_fake_image_info()
file_mock = mock.Mock()
@@ -1390,6 +1392,7 @@ class TestImageDownload(base.IronicAgentTest):
@mock.patch('time.sleep', autospec=True)
def test_download_image_retries(self, sleep_mock, requests_mock,
time_mock):
self.config(image_download_connection_retries=2)
response = requests_mock.return_value
response.status_code = 500
response.text = 'Oops'
@@ -1406,7 +1409,7 @@ class TestImageDownload(base.IronicAgentTest):
stream=True, proxies={},
timeout=60)
self.assertEqual(3, requests_mock.call_count)
sleep_mock.assert_called_with(5)
sleep_mock.assert_called_with(10)
self.assertEqual(2, sleep_mock.call_count)

@mock.patch('time.sleep', autospec=True)
@@ -1431,7 +1434,7 @@ class TestImageDownload(base.IronicAgentTest):
stream=True, proxies={},
timeout=60)
self.assertEqual(3, requests_mock.call_count)
sleep_mock.assert_called_with(5)
sleep_mock.assert_called_with(10)
self.assertEqual(2, sleep_mock.call_count)

def test_download_image_and_checksum(self, requests_mock, md5_mock):
@@ -1531,6 +1534,7 @@ foobar irrelevant file.img
standby.ImageDownload, image_info)

def test_download_image_and_checksum_failed(self, requests_mock, md5_mock):
self.config(image_download_connection_retry_interval=0)
content = ['SpongeBob', 'SquarePants']
cs_response = mock.Mock()
cs_response.status_code = 400


+ 8
- 0
releasenotes/notes/extend-retry-timeout-30c930a33d97c193.yaml View File

@@ -0,0 +1,8 @@
---
fixes:
- |
Fixes the short timeout retries interval, which was previously ``5``
seconds, to a length that will allow the agent to retry after a
network interruption. The time between retries is now ``10`` seconds,
and the number of retries are set to ``9`` to help ensure intermittent
network outages do not cause recoverable failures.

Loading…
Cancel
Save