Change variable used by log message

The code was changing the status of a task and then logging an
info message about the change using the already-changed variable.
This patch saves the old status before the task status is modified
so that the status transition can be accurately reported in the log.

Change-Id: I84fef1d710f24f601971a348f53d74b6a6d6a2f9
Closes-bug: #1713740
This commit is contained in:
Brian Rosmaita 2017-08-29 11:10:22 -04:00
parent 02cd5cba70
commit e1321298e7
1 changed files with 2 additions and 2 deletions

View File

@ -403,12 +403,12 @@ class Task(object):
def _set_task_status(self, new_status):
if self._validate_task_status_transition(self.status, new_status):
old_status = self.status
self._status = new_status
LOG.info(_LI("Task [%(task_id)s] status changing from "
"%(cur_status)s to %(new_status)s"),
{'task_id': self.task_id, 'cur_status': self.status,
{'task_id': self.task_id, 'cur_status': old_status,
'new_status': new_status})
self._status = new_status
else:
LOG.error(_LE("Task [%(task_id)s] status failed to change from "
"%(cur_status)s to %(new_status)s"),