DNM - Debuggin for bug #2034704

Capture console log if instance in task_state == 'powering-off'
when target state is "SHUTOFF".

Change-Id: Ic9eb7ec3d89c8694be5fe8117dedec6c29430d54
This commit is contained in:
Harald Jensås 2023-09-11 11:37:10 +02:00
parent d01331db06
commit 19c71d6e26
No known key found for this signature in database
GPG Key ID: 693852E00DCEA408
1 changed files with 24 additions and 0 deletions

View File

@ -110,11 +110,28 @@ class OpenStackBmc(bmc.Bmc):
self.log('Shutting down in response to BMC cold reset request')
sys.exit(0)
def _capture_instance_console_log(self):
try:
console = self.novaclient.servers.get_console_output(
self.instance, length=200)
self.log('######## START %(instance)s-console-log ########\n'
'%(console)s\n'
'######## END %(instance)s-console-log ########'
% {'instance': self.instance, 'console': console})
except exceptions.NotFound:
self.log('Cannot capture console log for instance %s, the guest '
'does not have a console log available.' % self.instance)
def _instance_active(self):
no_cached_data = (self.cached_status is None)
instance_changing_state = (self.cached_status != self.target_status)
cache_disabled = (not self.cache_status)
if instance_changing_state:
self.log("DEBUG - instance %s changing state - target %s" %
(self.instance, self.target_status))
instance = None
if (no_cached_data or instance_changing_state or cache_disabled):
instance = self.novaclient.servers.get(self.instance)
self.cached_status = instance.status
@ -124,6 +141,13 @@ class OpenStackBmc(bmc.Bmc):
instance_is_shutoff = (self.cached_status == 'SHUTOFF')
instance_is_powering_on = (self.cached_task == 'powering-on')
if self.target_status == "SHUTOFF" and instance_is_active:
if instance is None:
instance = self.novaclient.servers.get(self.instance)
self.log("DEBUG - instance %s - %s" % (
self.instance, instance.to_dict()))
if getattr(instance, 'OS-EXT-STS:task_state') == 'powering-off':
self._capture_instance_console_log()
return (
instance_is_active or
(instance_is_shutoff and instance_is_powering_on)