summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDinesh Bhor <dinesh.bhor@nttdata.com>2017-07-18 18:50:38 +0530
committerDinesh Bhor <dinesh.bhor@nttdata.com>2017-07-27 09:53:25 +0530
commit5d34fb847eef3815f357ad0d069e2d41baa4a60c (patch)
tree607949e9eeed60b0ac140972967c22b98df946f5
parent3dfa413f00753006b7baff7e924701f4e54efc3a (diff)
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] d4dd11d7bd5caaa4cbefeed62ae7fc5162fb0f25 Change-Id: I2139976f6774b10518c7455a9af1b32b1e7b3e7d
Notes
Notes (review): Code-Review+2: Tushar Patil <tushar.vitthal.patil@gmail.com> Code-Review+2: Rikimaru Honjo <honjo.rikimaru@po.ntt-tx.co.jp> Workflow+1: Rikimaru Honjo <honjo.rikimaru@po.ntt-tx.co.jp> Verified+2: Jenkins Submitted-by: Jenkins Submitted-at: Thu, 27 Jul 2017 09:48:42 +0000 Reviewed-on: https://review.openstack.org/485205 Project: openstack/masakari Branch: refs/heads/master
-rw-r--r--masakari/compute/nova.py21
-rw-r--r--masakari/context.py3
-rw-r--r--masakari/tests/unit/compute/test_nova.py12
3 files changed, 22 insertions, 14 deletions
diff --git a/masakari/compute/nova.py b/masakari/compute/nova.py
index 493b7de..6b44a28 100644
--- a/masakari/compute/nova.py
+++ b/masakari/compute/nova.py
@@ -93,7 +93,8 @@ def novaclient(context, timeout=None):
93 CONF.os_privileged_user_name, None, 93 CONF.os_privileged_user_name, None,
94 auth_token=CONF.os_privileged_user_password, 94 auth_token=CONF.os_privileged_user_password,
95 project_name=CONF.os_privileged_user_tenant, 95 project_name=CONF.os_privileged_user_tenant,
96 service_catalog=context.service_catalog) 96 service_catalog=context.service_catalog,
97 global_request_id=context.global_id)
97 98
98 # User needs to authenticate to Keystone before querying Nova, so we set 99 # User needs to authenticate to Keystone before querying Nova, so we set
99 # auth_url to the identity service endpoint 100 # auth_url to the identity service endpoint
@@ -112,14 +113,16 @@ def novaclient(context, timeout=None):
112 project_name=context.project_name) 113 project_name=context.project_name)
113 keystone_session = keystoneauth1.session.Session(auth=auth) 114 keystone_session = keystoneauth1.session.Session(auth=auth)
114 115
115 client_obj = nova_client.Client(api_versions.APIVersion(NOVA_API_VERSION), 116 client_obj = nova_client.Client(
116 session=keystone_session, 117 api_versions.APIVersion(NOVA_API_VERSION),
117 insecure=CONF.nova_api_insecure, 118 session=keystone_session,
118 timeout=timeout, 119 insecure=CONF.nova_api_insecure,
119 region_name=CONF.os_region_name, 120 timeout=timeout,
120 endpoint_type=endpoint_type, 121 global_request_id=context.global_id,
121 cacert=CONF.nova_ca_certificates_file, 122 region_name=CONF.os_region_name,
122 extensions=nova_extensions) 123 endpoint_type=endpoint_type,
124 cacert=CONF.nova_ca_certificates_file,
125 extensions=nova_extensions)
123 126
124 return client_obj 127 return client_obj
125 128
diff --git a/masakari/context.py b/masakari/context.py
index ed35bee..499cab9 100644
--- a/masakari/context.py
+++ b/masakari/context.py
@@ -102,7 +102,8 @@ class RequestContext(context.RequestContext):
102 resource_uuid=kwargs.pop('resource_uuid', None), 102 resource_uuid=kwargs.pop('resource_uuid', None),
103 overwrite=overwrite, 103 overwrite=overwrite,
104 roles=roles, 104 roles=roles,
105 is_admin_project=kwargs.pop('is_admin_project', True)) 105 is_admin_project=kwargs.pop('is_admin_project', True),
106 global_request_id=kwargs.pop('global_request_id', None))
106 # oslo_context's RequestContext.to_dict() generates this field, we can 107 # oslo_context's RequestContext.to_dict() generates this field, we can
107 # safely ignore this as we don't use it. 108 # safely ignore this as we don't use it.
108 kwargs.pop('user_identity', None) 109 kwargs.pop('user_identity', None)
diff --git a/masakari/tests/unit/compute/test_nova.py b/masakari/tests/unit/compute/test_nova.py
index 3efa5be..3f797a4 100644
--- a/masakari/tests/unit/compute/test_nova.py
+++ b/masakari/tests/unit/compute/test_nova.py
@@ -57,7 +57,8 @@ class NovaClientTestCase(test.TestCase):
57 p_api_version(nova.NOVA_API_VERSION), 57 p_api_version(nova.NOVA_API_VERSION),
58 session=p_session.return_value, region_name=None, 58 session=p_session.return_value, region_name=None,
59 insecure=False, endpoint_type='publicURL', cacert=None, 59 insecure=False, endpoint_type='publicURL', cacert=None,
60 timeout=None, extensions=nova.nova_extensions) 60 timeout=None, global_request_id=self.ctx.global_id,
61 extensions=nova.nova_extensions)
61 62
62 @mock.patch('novaclient.api_versions.APIVersion') 63 @mock.patch('novaclient.api_versions.APIVersion')
63 @mock.patch('novaclient.client.Client') 64 @mock.patch('novaclient.client.Client')
@@ -74,7 +75,8 @@ class NovaClientTestCase(test.TestCase):
74 p_api_version(nova.NOVA_API_VERSION), 75 p_api_version(nova.NOVA_API_VERSION),
75 session=p_session.return_value, region_name=None, 76 session=p_session.return_value, region_name=None,
76 insecure=False, endpoint_type='publicURL', cacert=None, 77 insecure=False, endpoint_type='publicURL', cacert=None,
77 timeout=None, extensions=nova.nova_extensions) 78 timeout=None, global_request_id=self.ctx.global_id,
79 extensions=nova.nova_extensions)
78 80
79 @mock.patch('novaclient.api_versions.APIVersion') 81 @mock.patch('novaclient.api_versions.APIVersion')
80 @mock.patch('novaclient.client.Client') 82 @mock.patch('novaclient.client.Client')
@@ -93,7 +95,8 @@ class NovaClientTestCase(test.TestCase):
93 p_api_version(nova.NOVA_API_VERSION), 95 p_api_version(nova.NOVA_API_VERSION),
94 session=p_session.return_value, region_name=None, 96 session=p_session.return_value, region_name=None,
95 insecure=False, endpoint_type='publicURL', cacert=None, 97 insecure=False, endpoint_type='publicURL', cacert=None,
96 timeout=None, extensions=nova.nova_extensions) 98 timeout=None, global_request_id=self.ctx.global_id,
99 extensions=nova.nova_extensions)
97 100
98 @mock.patch('novaclient.api_versions.APIVersion') 101 @mock.patch('novaclient.api_versions.APIVersion')
99 @mock.patch('novaclient.client.Client') 102 @mock.patch('novaclient.client.Client')
@@ -111,7 +114,8 @@ class NovaClientTestCase(test.TestCase):
111 p_api_version(nova.NOVA_API_VERSION), 114 p_api_version(nova.NOVA_API_VERSION),
112 session=p_session.return_value, region_name='farfaraway', 115 session=p_session.return_value, region_name='farfaraway',
113 insecure=False, endpoint_type='publicURL', cacert=None, 116 insecure=False, endpoint_type='publicURL', cacert=None,
114 timeout=None, extensions=nova.nova_extensions) 117 timeout=None, global_request_id=self.ctx.global_id,
118 extensions=nova.nova_extensions)
115 119
116 120
117class NovaApiTestCase(test.TestCase): 121class NovaApiTestCase(test.TestCase):