Change log level based on node status

While the status node change message is purely informational, it
can contain also failed states transitions.
Moving the level from INFO to ERROR if the provision_state is
'failed' can help in detecting the transition message when
troubleshooting issues.

Change-Id: I79ff7cb8b9d33bc2837d41126fba269a5d4b1cda
(cherry picked from commit b8fa188a29)
This commit is contained in:
Riccardo Pittau 2019-09-25 14:38:30 +02:00
parent 18a45e8b49
commit 7b3d60c106

View File

@ -486,12 +486,20 @@ class TaskManager(object):
# publish the state transition by saving the Node
self.node.save()
LOG.info('Node %(node)s moved to provision state "%(state)s" from '
'state "%(previous)s"; target provision state is '
'"%(target)s"',
{'node': self.node.uuid, 'state': self.node.provision_state,
'target': self.node.target_provision_state,
'previous': self._prev_provision_state})
log_message = ('Node %(node)s moved to provision state "%(state)s" '
'from state "%(previous)s"; target provision state is '
'"%(target)s"' %
{'node': self.node.uuid,
'state': self.node.provision_state,
'target': self.node.target_provision_state,
'previous': self._prev_provision_state})
if (self.node.provision_state.endswith('failed') or
self.node.provision_state == 'error'):
LOG.error(log_message)
else:
LOG.info(log_message)
if callback is None:
self._notify_provision_state_change()