Track status report timestamp

Report status messages were ordered by the time
they were inserted into database. And that is the
time they were received and processed not the
time the report message was generated. So if
deployment generates reports faster than they
get processed it can be that they accumulate
in RabbitMQ and then received by the API not
in original order. Another possibility is that
several API instances would get those messages
and because of the race condition insert them
into database in wrong order.

With this fix report timestamp becomes part
of the report itself and is inserted into "created"
table column. Thus created is now when the
report was created, not the database record.

Change-Id: I1d41d644ed399cb9d58192e567f11187fa2cf593
Closes-Bug: #1462270
This commit is contained in:
Stan Lagun 2016-04-01 13:59:24 +03:00
parent 14f08ecc85
commit 51de28f7a9
2 changed files with 5 additions and 1 deletions

View File

@ -178,6 +178,8 @@ def report_notification(report):
del report['id']
status = models.Status()
if 'timestamp' in report:
report['created'] = timeutils.parse_isotime(report.pop('timestamp'))
status.update(report)
unit = session.get_session()

View File

@ -16,6 +16,7 @@
from oslo_config import cfg
import oslo_messaging as messaging
from oslo_utils import timeutils
import six
from murano.common import uuidutils
@ -47,7 +48,8 @@ class StatusReporter(object):
'text': msg,
'details': details,
'level': level,
'environment_id': self._environment_id
'environment_id': self._environment_id,
'timestamp': timeutils.isotime()
}
self._notifier.info({}, 'murano.report_notification', body)