Send global_request_id to nova when calls are made
This patch adds the global_request_id to the constructor for nova
client, which will pass the global_request_id into nova services
on all API calls. Supporting global_request_id makes debugging [1]
easier when request touches many services in cloud. The masakari
request-id will be sent to nova in the request header like below and
it will be available with context.global_id:
-H "X-OpenStack-Request-ID: req-1a9b7b24-02ed-4400-bcc3-cc1bcbb59147"
Masakari is already using newer python-novacliant which supports
global_request_id [2].
This patch also fixes the below debug log message which gets emitted
when any argument gets dropped while creating request context:
"Arguments dropped when creating context: {u'global_request_id': None}"
As decided earlier while fixing the issue [3] this patch adds the
'global_request_id' to the base RequestContext hence removes the
earlier debug log message.
[1] I65de8261746b25d45e105394f4eeb95b9cb3bd42
[2] I5b247f75edeea9da50fe524eadf5f9a2c626d665
[3] d4dd11d7bd
Change-Id: I2139976f6774b10518c7455a9af1b32b1e7b3e7d
This commit is contained in:
parent
3dfa413f00
commit
5d34fb847e
|
@ -93,7 +93,8 @@ def novaclient(context, timeout=None):
|
|||
CONF.os_privileged_user_name, None,
|
||||
auth_token=CONF.os_privileged_user_password,
|
||||
project_name=CONF.os_privileged_user_tenant,
|
||||
service_catalog=context.service_catalog)
|
||||
service_catalog=context.service_catalog,
|
||||
global_request_id=context.global_id)
|
||||
|
||||
# User needs to authenticate to Keystone before querying Nova, so we set
|
||||
# auth_url to the identity service endpoint
|
||||
|
@ -112,14 +113,16 @@ def novaclient(context, timeout=None):
|
|||
project_name=context.project_name)
|
||||
keystone_session = keystoneauth1.session.Session(auth=auth)
|
||||
|
||||
client_obj = nova_client.Client(api_versions.APIVersion(NOVA_API_VERSION),
|
||||
session=keystone_session,
|
||||
insecure=CONF.nova_api_insecure,
|
||||
timeout=timeout,
|
||||
region_name=CONF.os_region_name,
|
||||
endpoint_type=endpoint_type,
|
||||
cacert=CONF.nova_ca_certificates_file,
|
||||
extensions=nova_extensions)
|
||||
client_obj = nova_client.Client(
|
||||
api_versions.APIVersion(NOVA_API_VERSION),
|
||||
session=keystone_session,
|
||||
insecure=CONF.nova_api_insecure,
|
||||
timeout=timeout,
|
||||
global_request_id=context.global_id,
|
||||
region_name=CONF.os_region_name,
|
||||
endpoint_type=endpoint_type,
|
||||
cacert=CONF.nova_ca_certificates_file,
|
||||
extensions=nova_extensions)
|
||||
|
||||
return client_obj
|
||||
|
||||
|
|
|
@ -102,7 +102,8 @@ class RequestContext(context.RequestContext):
|
|||
resource_uuid=kwargs.pop('resource_uuid', None),
|
||||
overwrite=overwrite,
|
||||
roles=roles,
|
||||
is_admin_project=kwargs.pop('is_admin_project', True))
|
||||
is_admin_project=kwargs.pop('is_admin_project', True),
|
||||
global_request_id=kwargs.pop('global_request_id', None))
|
||||
# oslo_context's RequestContext.to_dict() generates this field, we can
|
||||
# safely ignore this as we don't use it.
|
||||
kwargs.pop('user_identity', None)
|
||||
|
|
|
@ -57,7 +57,8 @@ class NovaClientTestCase(test.TestCase):
|
|||
p_api_version(nova.NOVA_API_VERSION),
|
||||
session=p_session.return_value, region_name=None,
|
||||
insecure=False, endpoint_type='publicURL', cacert=None,
|
||||
timeout=None, extensions=nova.nova_extensions)
|
||||
timeout=None, global_request_id=self.ctx.global_id,
|
||||
extensions=nova.nova_extensions)
|
||||
|
||||
@mock.patch('novaclient.api_versions.APIVersion')
|
||||
@mock.patch('novaclient.client.Client')
|
||||
|
@ -74,7 +75,8 @@ class NovaClientTestCase(test.TestCase):
|
|||
p_api_version(nova.NOVA_API_VERSION),
|
||||
session=p_session.return_value, region_name=None,
|
||||
insecure=False, endpoint_type='publicURL', cacert=None,
|
||||
timeout=None, extensions=nova.nova_extensions)
|
||||
timeout=None, global_request_id=self.ctx.global_id,
|
||||
extensions=nova.nova_extensions)
|
||||
|
||||
@mock.patch('novaclient.api_versions.APIVersion')
|
||||
@mock.patch('novaclient.client.Client')
|
||||
|
@ -93,7 +95,8 @@ class NovaClientTestCase(test.TestCase):
|
|||
p_api_version(nova.NOVA_API_VERSION),
|
||||
session=p_session.return_value, region_name=None,
|
||||
insecure=False, endpoint_type='publicURL', cacert=None,
|
||||
timeout=None, extensions=nova.nova_extensions)
|
||||
timeout=None, global_request_id=self.ctx.global_id,
|
||||
extensions=nova.nova_extensions)
|
||||
|
||||
@mock.patch('novaclient.api_versions.APIVersion')
|
||||
@mock.patch('novaclient.client.Client')
|
||||
|
@ -111,7 +114,8 @@ class NovaClientTestCase(test.TestCase):
|
|||
p_api_version(nova.NOVA_API_VERSION),
|
||||
session=p_session.return_value, region_name='farfaraway',
|
||||
insecure=False, endpoint_type='publicURL', cacert=None,
|
||||
timeout=None, extensions=nova.nova_extensions)
|
||||
timeout=None, global_request_id=self.ctx.global_id,
|
||||
extensions=nova.nova_extensions)
|
||||
|
||||
|
||||
class NovaApiTestCase(test.TestCase):
|
||||
|
|
Loading…
Reference in New Issue