Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retry api calls on 'service unavailable' #266

Open
wants to merge 1 commit into
base: stable/rocky-m3
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions nova/conf/glance.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,20 @@

Specifies the number of retries when uploading / downloading
an image to / from glance. 0 means no retries.
"""),
cfg.IntOpt('http_retries',
default=3,
min=0,
help="""
Number of times glanceclient should retry on any failed http call.

0 means connection is attempted only once. Setting it to any positive integer
means that on failure connection is retried that many times e.g. setting it
to 3 means total attempts to connect will be 4.

Possible values:

* Any integer value. 0 means connection is attempted only once
"""),
cfg.ListOpt('allowed_direct_url_schemes',
default=[],
Expand Down
5 changes: 4 additions & 1 deletion nova/image/glance.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ def _glanceclient_from_endpoint(context, endpoint, version):

return glanceclient.Client(version, session=sess, auth=auth,
endpoint_override=endpoint,
global_request_id=context.global_id)
global_request_id=context.global_id,
connect_retries=CONF.glance.http_retries,
status_code_retries=CONF.glance.http_retries
)


def generate_glance_url(context):
Expand Down
3 changes: 2 additions & 1 deletion nova/network/neutronv2/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ def get_client(context, admin=False):
client_args = dict(session=session,
auth=auth_plugin,
global_request_id=context.global_id,
connect_retries=CONF.neutron.http_retries)
connect_retries=CONF.neutron.http_retries,
status_code_retries=CONF.neutron.http_retries)

if CONF.neutron.url:
# TODO(efried): Remove in Rocky
Expand Down
4 changes: 3 additions & 1 deletion nova/tests/unit/image/test_glance.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,8 +374,10 @@ def test_glanceclient_with_ks_session(self, mock_client, mock_load,
self.assertEqual(session, glance._SESSION)
# Ensure new client created every time
client_call = mock.call(2, auth="fake_auth",
connect_retries=glance.CONF.glance.http_retries,
endpoint_override=endpoint, session=session,
global_request_id='reqid')
global_request_id='reqid',
status_code_retries=glance.CONF.glance.http_retries)
mock_client.assert_has_calls([client_call, client_call])
self.assertEqual("a", result1)
self.assertEqual("b", result2)
Expand Down
1 change: 1 addition & 0 deletions nova/volume/cinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ def cinderclient(context, microversion=None, skip_version_check=False,
auth=auth,
endpoint_override=endpoint_override,
connect_retries=CONF.cinder.http_retries,
status_code_retries=CONF.cinder.http_retries,
global_request_id=context.global_id,
**service_parameters)

Expand Down