Skip to content

Commit

Permalink
Update accessing nova compute logs for RBD check
Browse files Browse the repository at this point in the history
Nova compute logs are no longer accessible via accessing the
nova_compute container downstream. Instead the nova service logs are
available directly on the host via journalctl. Updated LogParserClient
to conditionally access nova service logs either via host or container.

Change-Id: I2cf0ded367e85fca1e49a2cab48adb23b1ed9807
  • Loading branch information
jamepark4 committed Oct 7, 2024
1 parent 2a09062 commit 261de3a
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 35 deletions.
1 change: 1 addition & 0 deletions .zuul.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@
whitebox-tempest-plugin: https://opendev.org/openstack/whitebox-tempest-plugin.git
tempest_test_regex: '^whitebox_tempest_plugin.api.compute.test_rbd_direct_download'
devstack_localrc:
NOVA_SERVICE_REPORT_INTERVAL: 10
COMPUTE_FEATURE_RBD_DOWNLOAD: True
TEMPEST_PLUGINS: /opt/stack/whitebox-tempest-plugin
WHITEBOX_PRIVKEY_PATH: /home/tempest/.ssh/id_rsa
Expand Down
69 changes: 37 additions & 32 deletions whitebox_tempest_plugin/api/compute/test_rbd_direct_download.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,37 +38,42 @@ def skip_checks(cls):
raise cls.skipException(skip_msg)

def test_rbd_logs_and_conf(self):
base_server = self.create_test_server(wait_until='ACTIVE')
image = self.create_image_from_server(
base_server['id'],
name='base-server-img',
wait_until='ACTIVE'
)
# Creating a server from above image ensures a fresh
# attempt is made to download an image from the rbd
# pool to the local compute
server = self.create_test_server(wait_until='ACTIVE',
image_id=image['id'])
with self.config_all_computes(
('libvirt', 'images_type', 'default'),
):

# Grab image id from newly created server
detailed_server_data = \
self.os_admin.servers_client.show_server(server['id'])['server']
image_id = detailed_server_data['image']['id']
base_server = self.create_test_server(wait_until='ACTIVE')
image = self.create_image_from_server(
base_server['id'],
name='base-server-img',
wait_until='ACTIVE'
)
# Creating a server from above image ensures a fresh
# attempt is made to download an image from the rbd
# pool to the local compute
server = self.create_test_server(wait_until='ACTIVE',
image_id=image['id'])

host = self.get_host_for_server(server['id'])
host_sm = clients.NovaServiceManager(host, 'nova-compute',
self.os_admin.services_client)
rbd_pool = host_sm.get_conf_opt('glance', 'rbd_pool')
# Assert RBD direct download conf options
self.assertEqual('images', rbd_pool)
self.assertTrue(host_sm.get_conf_opt('glance', 'enable_rbd_download'))
log_query_string = f"Attempting to export RBD image: " \
f"[[]pool_name: {rbd_pool}[]] [[]image_uuid: " \
f"{image_id}[]]"
logs_client = clients.LogParserClient(host)
# Assert if log with specified image is found
self.assertTrue(len(logs_client.parse(log_query_string)))
path = self.get_server_blockdevice_path(server['id'], 'vda')
# Assert image disk is present in ephemeral
# instances_path and not in rbd
self.assertIsNotNone(path) and self.assertNotIn('rbd', path)
# Grab image id from newly created server
detailed_server_data = \
self.os_admin.servers_client.show_server(server['id'])
image_id = detailed_server_data['server']['image']['id']

host = self.get_host_for_server(server['id'])
host_sm = clients.NovaServiceManager(
host, 'nova-compute', self.os_admin.services_client)
rbd_pool = host_sm.get_conf_opt('glance', 'rbd_pool')
# Assert RBD direct download conf options
self.assertEqual('images', rbd_pool)
self.assertTrue(host_sm.get_conf_opt('glance',
'enable_rbd_download'))
log_query_string = f"Attempting to export RBD image: " \
f"[[]pool_name: {rbd_pool}[]] [[]image_uuid: " \
f"{image_id}[]]"
logs_client = clients.LogParserClient(host)
# Assert if log with specified image is found
self.assertTrue(len(logs_client.parse(log_query_string)))
path = self.get_server_blockdevice_path(server['id'], 'vda')
# Assert image disk is present in ephemeral
# instances_path and not in rbd
self.assertIsNotNone(path) and self.assertNotIn('rbd', path)
4 changes: 4 additions & 0 deletions whitebox_tempest_plugin/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@
help="Name of the utility to run LogParserClient commands. "
"Currently, supported values are 'journalctl' (default) "
"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(
'state_path',
default="/var/lib/nova",
Expand Down
10 changes: 7 additions & 3 deletions whitebox_tempest_plugin/services/clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,14 @@ class LogParserClient(SSHClient):
def parse(self, query_string):
log_query_command = CONF.whitebox_nova_compute.log_query_command
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:
command = 'journalctl -u devstack@n-cpu -g \'%s\'' % query_string
return self.execute(command, container_name='nova_compute', sudo=True)
unit = CONF.whitebox_nova_compute.journalctl_unit
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):
Expand Down

0 comments on commit 261de3a

Please sign in to comment.