From f79c9ee89a6929a5c6f7d154f59a8443b244bb4d Mon Sep 17 00:00:00 2001 From: Ilya Etingof Date: Wed, 19 Feb 2020 23:29:14 +0100 Subject: [PATCH] Add `error` instance status to `vbmc` reporing Added `error` status to `vbmc list` and `vbmc start` commands output. If the instance is failing to start, such instance will be shown as being in `error` satte rather than being `down`. Change-Id: I3ad307f97442c6b30c3e60bd8186bfb30903c0b0 Story: 2006457 Task: 36378 --- .../show-error-status-13456782b3a5a6e2.yaml | 5 +++++ virtualbmc/manager.py | 20 +++++++++++-------- 2 files changed, 17 insertions(+), 8 deletions(-) create mode 100644 releasenotes/notes/show-error-status-13456782b3a5a6e2.yaml diff --git a/releasenotes/notes/show-error-status-13456782b3a5a6e2.yaml b/releasenotes/notes/show-error-status-13456782b3a5a6e2.yaml new file mode 100644 index 0000000..28109f6 --- /dev/null +++ b/releasenotes/notes/show-error-status-13456782b3a5a6e2.yaml @@ -0,0 +1,5 @@ +features: + - | + Added ``error`` status to ``vbmc list`` and ``vbmc start`` commands + output. If the instance is failing to start, such instance will be shown + as ``error`` rather than being ``down``. diff --git a/virtualbmc/manager.py b/virtualbmc/manager.py index 6f57570..ddd4d38 100644 --- a/virtualbmc/manager.py +++ b/virtualbmc/manager.py @@ -27,6 +27,7 @@ LOG = log.get_logger() # BMC status RUNNING = 'running' DOWN = 'down' +ERROR = 'error' DEFAULT_SECTION = 'VirtualBMC' @@ -165,7 +166,7 @@ class VirtualBMCManager(object): if lets_enable: - if not instance: + if not instance or not instance.is_alive(): instance = multiprocessing.Process( name='vbmcd-managing-domain-%s' % domain_name, @@ -183,6 +184,13 @@ class VirtualBMCManager(object): '%(domain)s', {'domain': domain_name} ) + if not instance.is_alive(): + LOG.debug( + 'Found dead vBMC instance for domain %(domain)s ' + '(rc %(rc)s)', {'domain': domain_name, + 'rc': instance.exitcode} + ) + else: if instance: if instance.is_alive(): @@ -192,13 +200,7 @@ class VirtualBMCManager(object): '%(domain)s', {'domain': domain_name} ) - if instance and not instance.is_alive(): - del self._running_domains[domain_name] - LOG.debug( - 'Reaped vBMC instance for domain %(domain)s ' - '(rc %(rc)s)', {'domain': domain_name, - 'rc': instance.exitcode} - ) + self._running_domains.pop(domain_name, None) def _show(self, domain_name): bmc_config = self._parse_config(domain_name) @@ -214,6 +216,8 @@ class VirtualBMCManager(object): if instance and instance.is_alive(): show_options['status'] = RUNNING + elif instance and not instance.is_alive(): + show_options['status'] = ERROR else: show_options['status'] = DOWN