From ed7767865f891d5a90915f3486d567e2ac649a7e Mon Sep 17 00:00:00 2001 From: Keigo Noha Date: Fri, 10 Jul 2020 10:32:02 +0900 Subject: [PATCH] Change default num_retries for glance to 3 Previously, the default value of num_retries for glance is 0. It means that the request to glance is sent only one time. On the other hand, neutron and cinder clients set the default value to 3. To align the default value for retry to other components, we should change the default value to 3. Closes-Bug: #1888168 Change-Id: Ibbd4bd26408328b9e1a1128b3794721405631193 (cherry picked from commit 662af9fab6eacb46bcaee38d076d33c2c0f82b9b) (cherry picked from commit 1f9dd694b937cc55a81a64fdce442829f009afb3) (cherry picked from commit ca2fd8098a47cf2c38351dc4c8c65c7c5fe0afc3) --- nova/conf/glance.py | 2 +- nova/tests/unit/virt/xenapi/image/test_glance.py | 12 ++++++------ nova/tests/unit/virt/xenapi/test_vm_utils.py | 2 +- ...increase_glance_num_retries-ddfcd7053631882b.yaml | 11 +++++++++++ 4 files changed, 19 insertions(+), 8 deletions(-) create mode 100644 releasenotes/notes/increase_glance_num_retries-ddfcd7053631882b.yaml diff --git a/nova/conf/glance.py b/nova/conf/glance.py index b96f437b0f36..694855e219cd 100644 --- a/nova/conf/glance.py +++ b/nova/conf/glance.py @@ -44,7 +44,7 @@ Possible values: (i.e. "http://10.0.1.0:9292" or "https://my.glance.server/image"). """), cfg.IntOpt('num_retries', - default=0, + default=3, min=0, help=""" Enable glance operation retries. diff --git a/nova/tests/unit/virt/xenapi/image/test_glance.py b/nova/tests/unit/virt/xenapi/image/test_glance.py index 3994af17926e..be49622e7332 100644 --- a/nova/tests/unit/virt/xenapi/image/test_glance.py +++ b/nova/tests/unit/virt/xenapi/image/test_glance.py @@ -148,7 +148,7 @@ class TestGlanceStore(stubs.XenAPITestBaseNoDB): mock_sr_path.assert_called_once_with(self.session) mock_extra_header.assert_called_once_with(self.context) mock_upload.assert_called_once_with( - self.session, 0, mock.ANY, mock.ANY, 'fake_image_uuid', + self.session, 3, mock.ANY, mock.ANY, 'fake_image_uuid', 'fake_sr_path', 'fake_extra_header', **params) @mock.patch.object(utils, 'get_auto_disk_config_from_instance') @@ -169,7 +169,7 @@ class TestGlanceStore(stubs.XenAPITestBaseNoDB): mock_sr_path.assert_called_once_with(self.session) mock_extra_header.assert_called_once_with(self.context) mock_upload.assert_called_once_with( - self.session, 0, mock.ANY, mock.ANY, 'fake_image_uuid', + self.session, 3, mock.ANY, mock.ANY, 'fake_image_uuid', 'fake_sr_path', 'fake_extra_header', **params) mock_disk_config.assert_called_once_with(self.instance) @@ -190,7 +190,7 @@ class TestGlanceStore(stubs.XenAPITestBaseNoDB): mock_sr_path.assert_called_once_with(self.session) mock_extra_header.assert_called_once_with(self.context) mock_upload.assert_called_once_with( - self.session, 0, mock.ANY, mock.ANY, 'fake_image_uuid', + self.session, 3, mock.ANY, mock.ANY, 'fake_image_uuid', 'fake_sr_path', 'fake_extra_header', **params) mock_disk_config.assert_called_once_with(self.instance) @@ -211,7 +211,7 @@ class TestGlanceStore(stubs.XenAPITestBaseNoDB): mock_sr_path.assert_called_once_with(self.session) mock_extra_header.assert_called_once_with(self.context) mock_upload.assert_called_once_with( - self.session, 0, mock.ANY, mock.ANY, 'fake_image_uuid', + self.session, 3, mock.ANY, mock.ANY, 'fake_image_uuid', 'fake_sr_path', 'fake_extra_header', **params) @mock.patch.object(common_glance, 'generate_identity_headers') @@ -231,7 +231,7 @@ class TestGlanceStore(stubs.XenAPITestBaseNoDB): mock_sr_path.assert_called_once_with(self.session) mock_extra_header.assert_called_once_with(self.context) mock_upload.assert_called_once_with( - self.session, 0, mock.ANY, mock.ANY, 'fake_image_uuid', + self.session, 3, mock.ANY, mock.ANY, 'fake_image_uuid', 'fake_sr_path', 'fake_extra_header', **params) @mock.patch.object(time, 'sleep') @@ -330,5 +330,5 @@ class TestGlanceStore(stubs.XenAPITestBaseNoDB): mock_sr_path.assert_called_once_with(self.session) mock_extra_header.assert_called_once_with(self.context) mock_upload.assert_called_once_with( - self.session, 0, mock.ANY, mock.ANY, 'fake_image_uuid', + self.session, 3, mock.ANY, mock.ANY, 'fake_image_uuid', 'fake_sr_path', 'fake_extra_header', **params) diff --git a/nova/tests/unit/virt/xenapi/test_vm_utils.py b/nova/tests/unit/virt/xenapi/test_vm_utils.py index ef2d687e8f82..ef29e27e36ba 100644 --- a/nova/tests/unit/virt/xenapi/test_vm_utils.py +++ b/nova/tests/unit/virt/xenapi/test_vm_utils.py @@ -258,7 +258,7 @@ class FetchVhdImageTestCase(VMUtilsTestBase): self.mock_call_plugin.assert_called_once_with( 'glance.py', 'download_vhd2', - 0, + 3, mock.ANY, mock.ANY, extra_headers={'X-Auth-Token': 'auth_token', diff --git a/releasenotes/notes/increase_glance_num_retries-ddfcd7053631882b.yaml b/releasenotes/notes/increase_glance_num_retries-ddfcd7053631882b.yaml new file mode 100644 index 000000000000..72b5467bcd2d --- /dev/null +++ b/releasenotes/notes/increase_glance_num_retries-ddfcd7053631882b.yaml @@ -0,0 +1,11 @@ +--- +upgrade: + - | + The default for ``[glance] num_retries`` has changed from ``0`` to ``3``. + The option controls how many times to retry a Glance API call in response + to a HTTP connection failure. When deploying Glance behind HAproxy it is + possible for a response to arrive just after the HAproxy idle time. As a + result, an exception will be raised when the connection is closed resulting + in a failed request. By increasing the default value, Nova can be more + resilient to this scenario were HAproxy is misconfigured by retrying the + request.