Add timeout and retries to JSON RPC client

The necessary options are already in keystoneauth, but have empty
defaults. This patch changes timeout to 15 and adds 2 retries by default.

Change-Id: Idf8cfa54b77be6f5127d2c9d587a427aa0898802
This commit is contained in:
Dmitry Tantsur 2020-05-06 17:02:01 +02:00
parent 44ba19e851
commit 14524c265b
3 changed files with 14 additions and 2 deletions

View File

@ -41,11 +41,14 @@ def _get_session():
else:
auth = None
_SESSION = keystone.get_session('json_rpc', auth=auth)
_SESSION.headers = {
session = keystone.get_session('json_rpc', auth=auth)
session.headers = {
'Content-Type': 'application/json'
}
# Adds options like connect_retries
_SESSION = keystone.get_adapter('json_rpc', session=session)
return _SESSION

View File

@ -38,6 +38,8 @@ opts = [
def register_opts(conf):
conf.register_opts(opts, group='json_rpc')
auth.register_auth_opts(conf, 'json_rpc')
conf.set_default('timeout', 15, group='json_rpc')
conf.set_default('connect_retries', 2, group='json_rpc')
def list_opts():

View File

@ -0,0 +1,7 @@
---
fixes:
- |
Fixes the JSON RPC backend potentially hanging on inability to connect
to a conductor. The default timeout is now 15 seconds and 2 retries are
made. These values can be adjusted via the configuration options
``[json_rpc]timeout`` and ``[json_rpc]connect_retries`` accordingly.