diff options
author | Nikhil Manchanda <SlickNik@gmail.com> | 2015-03-31 20:23:08 -0700 |
---|---|---|
committer | Nikhil Manchanda <SlickNik@gmail.com> | 2015-04-01 11:31:55 -0700 |
commit | 80f898d3ba16d5c644447dbacf3a1bad6eaa6488 (patch) | |
tree | d296c9d2e0f8e35d5856709887897329cedda567 | |
parent | 0f898f786131097aa10c4c31bb9e54df13d6f9b7 (diff) | |
download | trove-80f898d3ba16d5c644447dbacf3a1bad6eaa6488.tar.gz |
Fixed NotificationTransformer to handle missing InstanceServiceStatus
Fixed NotificationTransformer to not send exists notifications for
new Trove instances which do not have an InstanceServiceStatus
created for them yet. The notifications for these instances will
eventually be sent during the next iteration of the scheduled task.
Change-Id: I002ab89f8c7715310f1890a34967c8172a5d96ef
Closes-Bug: 1379729
-rw-r--r-- | trove/extensions/mgmt/instances/models.py | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/trove/extensions/mgmt/instances/models.py b/trove/extensions/mgmt/instances/models.py index a81a53bb..a9232193 100644 --- a/trove/extensions/mgmt/instances/models.py +++ b/trove/extensions/mgmt/instances/models.py @@ -14,6 +14,7 @@ import datetime from trove.common import cfg +from trove.common import exception from trove.common import remote from trove.common import utils from trove.openstack.common import log as logging @@ -227,8 +228,18 @@ class NotificationTransformer(object): messages = [] db_infos = instance_models.DBInstance.find_all(deleted=False) for db_info in db_infos: - service_status = InstanceServiceStatus.find_by( - instance_id=db_info.id) + try: + service_status = InstanceServiceStatus.find_by( + instance_id=db_info.id) + except exception.ModelNotFoundError: + # There is a small window of opportunity during when the db + # resource for an instance exists, but no InstanceServiceStatus + # for it has yet been created. We skip sending the notification + # message for all such instances. These instance are too new + # and will get picked up the next round of notifications. + LOG.debug("InstanceServiceStatus not found for %s. " + "Will wait to send notification." % db_info.id) + continue instance = SimpleMgmtInstance(None, db_info, None, service_status) message = self.transform_instance(instance, audit_start, audit_end) messages.append(message) |