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: I5b705ee95c6fa2275937513aba0bcb0053c0901c
Closes-Bug: #1462270
This commit is contained in:
Stan Lagun 2016-04-01 14:06:42 +03:00
parent 3d1c2acaec
commit c499318107
2 changed files with 5 additions and 1 deletions

View File

@ -180,6 +180,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

@ -17,6 +17,7 @@ import types
from oslo_config import cfg
import oslo_messaging as messaging
from oslo_utils import timeutils
from murano.common import uuidutils
from murano.dsl import dsl
@ -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)