Merge "Update accessing nova compute logs for RBD check"

This commit is contained in:
Zuul 2024-10-08 02:03:38 +00:00 committed by Gerrit Code Review
commit 8e2eef0dde
4 changed files with 49 additions and 35 deletions

View File

@ -168,6 +168,7 @@
whitebox-tempest-plugin: https://opendev.org/openstack/whitebox-tempest-plugin.git whitebox-tempest-plugin: https://opendev.org/openstack/whitebox-tempest-plugin.git
tempest_test_regex: '^whitebox_tempest_plugin.api.compute.test_rbd_direct_download' tempest_test_regex: '^whitebox_tempest_plugin.api.compute.test_rbd_direct_download'
devstack_localrc: devstack_localrc:
NOVA_SERVICE_REPORT_INTERVAL: 10
COMPUTE_FEATURE_RBD_DOWNLOAD: True COMPUTE_FEATURE_RBD_DOWNLOAD: True
TEMPEST_PLUGINS: /opt/stack/whitebox-tempest-plugin TEMPEST_PLUGINS: /opt/stack/whitebox-tempest-plugin
WHITEBOX_PRIVKEY_PATH: /home/tempest/.ssh/id_rsa WHITEBOX_PRIVKEY_PATH: /home/tempest/.ssh/id_rsa

View File

@ -38,6 +38,10 @@ class TestRBDDirectDownload(base.BaseWhiteboxComputeTest):
raise cls.skipException(skip_msg) raise cls.skipException(skip_msg)
def test_rbd_logs_and_conf(self): def test_rbd_logs_and_conf(self):
with self.config_all_computes(
('libvirt', 'images_type', 'default'),
):
base_server = self.create_test_server(wait_until='ACTIVE') base_server = self.create_test_server(wait_until='ACTIVE')
image = self.create_image_from_server( image = self.create_image_from_server(
base_server['id'], base_server['id'],
@ -52,16 +56,17 @@ class TestRBDDirectDownload(base.BaseWhiteboxComputeTest):
# Grab image id from newly created server # Grab image id from newly created server
detailed_server_data = \ detailed_server_data = \
self.os_admin.servers_client.show_server(server['id'])['server'] self.os_admin.servers_client.show_server(server['id'])
image_id = detailed_server_data['image']['id'] image_id = detailed_server_data['server']['image']['id']
host = self.get_host_for_server(server['id']) host = self.get_host_for_server(server['id'])
host_sm = clients.NovaServiceManager(host, 'nova-compute', host_sm = clients.NovaServiceManager(
self.os_admin.services_client) host, 'nova-compute', self.os_admin.services_client)
rbd_pool = host_sm.get_conf_opt('glance', 'rbd_pool') rbd_pool = host_sm.get_conf_opt('glance', 'rbd_pool')
# Assert RBD direct download conf options # Assert RBD direct download conf options
self.assertEqual('images', rbd_pool) self.assertEqual('images', rbd_pool)
self.assertTrue(host_sm.get_conf_opt('glance', 'enable_rbd_download')) self.assertTrue(host_sm.get_conf_opt('glance',
'enable_rbd_download'))
log_query_string = f"Attempting to export RBD image: " \ log_query_string = f"Attempting to export RBD image: " \
f"[[]pool_name: {rbd_pool}[]] [[]image_uuid: " \ f"[[]pool_name: {rbd_pool}[]] [[]image_uuid: " \
f"{image_id}[]]" f"{image_id}[]]"

View File

@ -153,6 +153,10 @@ nova_compute_opts = [
help="Name of the utility to run LogParserClient commands. " help="Name of the utility to run LogParserClient commands. "
"Currently, supported values are 'journalctl' (default) " "Currently, supported values are 'journalctl' (default) "
"for devstack and 'zgrep' for TripleO"), "for devstack and 'zgrep' for TripleO"),
cfg.StrOpt(
'journalctl_unit',
default="devstack@n-cpu",
help="Unit to access when doing log query via journalctl"),
cfg.StrOpt( cfg.StrOpt(
'state_path', 'state_path',
default="/var/lib/nova", default="/var/lib/nova",

View File

@ -89,10 +89,14 @@ class LogParserClient(SSHClient):
def parse(self, query_string): def parse(self, query_string):
log_query_command = CONF.whitebox_nova_compute.log_query_command log_query_command = CONF.whitebox_nova_compute.log_query_command
if log_query_command == 'zgrep': if log_query_command == 'zgrep':
command = 'sh -c "zgrep \'%s\' /var/log/nova/*"' % query_string command = f'sh -c "zgrep \'{query_string}\' /var/log/nova/*"'
else: else:
command = 'journalctl -u devstack@n-cpu -g \'%s\'' % query_string unit = CONF.whitebox_nova_compute.journalctl_unit
return self.execute(command, container_name='nova_compute', sudo=True) command = f'journalctl -u {unit} -g \'{query_string}\''
services_dict = self.host_parameters.get('services', {})
nova_compute_srvc = services_dict.get('nova-compute')
container_name = nova_compute_srvc.get('container_name')
return self.execute(command, container_name=container_name, sudo=True)
class QEMUImgClient(SSHClient): class QEMUImgClient(SSHClient):