Merge "Adapt to new Keystone session creation timeouts"
This commit is contained in:
@@ -254,5 +254,8 @@ ANSIBLE_SUBCLOUD_ENROLL_PLAYBOOK = (
|
||||
# Sysinv client default timeout
|
||||
SYSINV_CLIENT_REST_DEFAULT_TIMEOUT = 600
|
||||
|
||||
# Keystone client connection timeout
|
||||
KEYSTONE_SERVER_DISCOVERY_TIMEOUT = 5
|
||||
|
||||
SUBCLOUD_ISO_PATH = "/opt/platform/iso"
|
||||
SUBCLOUD_FEED_PATH = "/var/www/pages/feed"
|
||||
|
@@ -217,9 +217,18 @@ class PeerKeystoneClient(base.DriverBase):
|
||||
project_name=user_project,
|
||||
project_domain_name=user_project_domain,
|
||||
)
|
||||
timeout = HTTP_CONNECT_TIMEOUT if timeout is None else timeout
|
||||
|
||||
if isinstance(timeout, tuple):
|
||||
discovery_timeout = float(timeout[0])
|
||||
read_timeout = float(timeout[1])
|
||||
else:
|
||||
discovery_timeout = consts.KEYSTONE_SERVER_DISCOVERY_TIMEOUT
|
||||
read_timeout = HTTP_CONNECT_TIMEOUT if timeout is None else read_timeout
|
||||
|
||||
return session.Session(
|
||||
auth=user_auth, additional_headers=consts.USER_HEADER, timeout=timeout
|
||||
auth=user_auth,
|
||||
additional_headers=consts.USER_HEADER,
|
||||
timeout=(discovery_timeout, read_timeout),
|
||||
)
|
||||
|
||||
def _create_keystone_client(self):
|
||||
|
@@ -240,7 +240,7 @@ class EndpointCache(object):
|
||||
user_password: str,
|
||||
user_project: str,
|
||||
user_project_domain: str,
|
||||
timeout: float = None,
|
||||
timeout=None,
|
||||
) -> session.Session:
|
||||
"""Get the admin session.
|
||||
|
||||
@@ -256,8 +256,8 @@ class EndpointCache(object):
|
||||
:type user_project: str
|
||||
:param user_project_domain: The user project domain.
|
||||
:type user_project_domain: str
|
||||
:param timeout: The timeout.
|
||||
:type timeout: int
|
||||
:param timeout: The discovery and read timeouts.
|
||||
:type timeout: Any
|
||||
:return: The admin session.
|
||||
:rtype: session.Session
|
||||
"""
|
||||
@@ -271,11 +271,20 @@ class EndpointCache(object):
|
||||
project_domain_name=user_project_domain,
|
||||
include_catalog=True,
|
||||
)
|
||||
timeout = (
|
||||
CONF.endpoint_cache.http_connect_timeout if timeout is None else timeout
|
||||
)
|
||||
|
||||
if isinstance(timeout, tuple):
|
||||
discovery_timeout = float(timeout[0])
|
||||
read_timeout = float(timeout[1])
|
||||
else:
|
||||
discovery_timeout = consts.KEYSTONE_SERVER_DISCOVERY_TIMEOUT
|
||||
read_timeout = (
|
||||
CONF.endpoint_cache.http_connect_timeout if timeout is None else timeout
|
||||
)
|
||||
|
||||
return session.Session(
|
||||
auth=user_auth, additional_headers=consts.USER_HEADER, timeout=timeout
|
||||
auth=user_auth,
|
||||
additional_headers=consts.USER_HEADER,
|
||||
timeout=(discovery_timeout, read_timeout),
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
@@ -365,7 +374,11 @@ class EndpointCache(object):
|
||||
auth = loader.load_from_options(
|
||||
auth_url=self.external_auth_url, token=token, project_id=project_id
|
||||
)
|
||||
return session.Session(auth=auth)
|
||||
|
||||
discovery_timeout = consts.KEYSTONE_SERVER_DISCOVERY_TIMEOUT
|
||||
read_timeout = CONF.endpoint_cache.http_connect_timeout
|
||||
|
||||
return session.Session(auth=auth, timeout=(discovery_timeout, read_timeout))
|
||||
|
||||
@classmethod
|
||||
@lockutils.synchronized(LOCK_NAME)
|
||||
|
@@ -120,13 +120,17 @@ class OrchestratorTestCase(base.BaseTestCase):
|
||||
self.mock_keystone_client = mock_patch.start()
|
||||
self.addCleanup(mock_patch.stop)
|
||||
|
||||
def _mock_endpoint_cache_from_keystone(self):
|
||||
mock_patch = mock.patch("dccommon.drivers.openstack.keystone_v3.EndpointCache")
|
||||
def _mock_keystone_endpoint_cache_get_admin_session(self):
|
||||
mock_patch = mock.patch(
|
||||
"dccommon.drivers.openstack.keystone_v3.EndpointCache.get_admin_session"
|
||||
)
|
||||
self.mock_endpoint_cache_from_keystone = mock_patch.start()
|
||||
self.addCleanup(mock_patch.stop)
|
||||
|
||||
def _mock_endpoint_cache(self):
|
||||
mock_patch = mock.patch("dccommon.endpoint_cache.EndpointCache")
|
||||
def _mock_endpoint_cache_get_admin_session(self):
|
||||
mock_patch = mock.patch(
|
||||
"dccommon.endpoint_cache.EndpointCache.get_admin_session"
|
||||
)
|
||||
self.mock_endpoint_cache = mock_patch.start()
|
||||
self.addCleanup(mock_patch.stop)
|
||||
|
||||
|
@@ -30,8 +30,8 @@ class BaseTestIdentitySyncThread(OrchestratorTestCase, mixins.BaseMixin):
|
||||
|
||||
self._mock_openstack_driver()
|
||||
self._mock_keystone_client()
|
||||
self._mock_endpoint_cache_from_keystone()
|
||||
self._mock_endpoint_cache()
|
||||
self._mock_keystone_endpoint_cache_get_admin_session()
|
||||
self._mock_endpoint_cache_get_admin_session()
|
||||
self._mock_m_dbs_client()
|
||||
self._mock_sc_dbs_client()
|
||||
self._mock_rpc_client_subcloud_state_client()
|
||||
|
Reference in New Issue
Block a user