Fix logging in vbmcd

Currently we log any exceptions as INFO and without much details.
Start logging them as ERROR with tracebacks. Add missing logging.

However, don't treat KeyboardInterrupt as an exception, just exit.
Also log the successful start-up, its absence is confusing.

Change-Id: I7464ce425ed05248152f264d64950e0ab1c0aec0
This commit is contained in:
Dmitry Tantsur 2020-03-04 11:56:16 +01:00
parent 834d02e616
commit b12197bb0d
2 changed files with 9 additions and 3 deletions

View File

@ -59,6 +59,8 @@ def main_loop(vbmc_manager, handle_command):
poller = zmq.Poller() poller = zmq.Poller()
poller.register(socket, zmq.POLLIN) poller.register(socket, zmq.POLLIN)
LOG.info('Started vBMC server on port %s', server_port)
while True: while True:
socks = dict(poller.poll(timeout=TIMER_PERIOD)) socks = dict(poller.poll(timeout=TIMER_PERIOD))
if socket in socks and socks[socket] == zmq.POLLIN: if socket in socks and socks[socket] == zmq.POLLIN:
@ -212,7 +214,9 @@ def application():
try: try:
main_loop(vbmc_manager, command_dispatcher) main_loop(vbmc_manager, command_dispatcher)
except KeyboardInterrupt:
LOG.info('Got keyboard interrupt, exiting')
vbmc_manager.periodic(shutdown=True)
except Exception as ex: except Exception as ex:
LOG.error( LOG.error(
'Control server error: %(error)s', {'error': ex} 'Control server error: %(error)s', {'error': ex}

View File

@ -124,7 +124,7 @@ class VirtualBMCManager(object):
vbmc = VirtualBMC(**bmc_config) vbmc = VirtualBMC(**bmc_config)
except Exception as ex: except Exception as ex:
LOG.error( LOG.exception(
'Error running vBMC with configuration ' 'Error running vBMC with configuration '
'%(opts)s: %(error)s', {'opts': show_options, '%(opts)s: %(error)s', {'opts': show_options,
'error': ex} 'error': ex}
@ -135,7 +135,7 @@ class VirtualBMCManager(object):
vbmc.listen(timeout=CONF['ipmi']['session_timeout']) vbmc.listen(timeout=CONF['ipmi']['session_timeout'])
except Exception as ex: except Exception as ex:
LOG.info( LOG.exception(
'Shutdown vBMC for domain %(domain)s, cause ' 'Shutdown vBMC for domain %(domain)s, cause '
'%(error)s', {'domain': show_options['domain_name'], '%(error)s', {'domain': show_options['domain_name'],
'error': ex} 'error': ex}
@ -299,6 +299,7 @@ class VirtualBMCManager(object):
lets_enable=True) lets_enable=True)
except Exception as e: except Exception as e:
LOG.exception('Failed to start domain %s', domain_name)
return 1, ('Failed to start domain %(domain)s. Error: ' return 1, ('Failed to start domain %(domain)s. Error: '
'%(error)s' % {'domain': domain_name, 'error': e}) '%(error)s' % {'domain': domain_name, 'error': e})
@ -311,6 +312,7 @@ class VirtualBMCManager(object):
self._vbmc_enabled(domain_name, lets_enable=False) self._vbmc_enabled(domain_name, lets_enable=False)
except Exception as ex: except Exception as ex:
LOG.exception('Failed to stop domain %s', domain_name)
return 1, str(ex) return 1, str(ex)
self._sync_vbmc_states() self._sync_vbmc_states()