summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikhil Manchanda <SlickNik@gmail.com>2015-03-31 20:23:08 -0700
committerIhar Hrachyshka <ihrachys@redhat.com>2015-04-08 11:34:40 +0000
commitef23c6ec9f7f932c2a95c70526297c32362b36a7 (patch)
treedd6540abbc1de4600d84fa770ae85d0af84ec36e
parent30ac4dd47606f8ea16cddece9e725dfa8ac84c62 (diff)
downloadtrove-ef23c6ec9f7f932c2a95c70526297c32362b36a7.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 (cherry picked from commit 80f898d3ba16d5c644447dbacf3a1bad6eaa6488)
-rw-r--r--trove/extensions/mgmt/instances/models.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/trove/extensions/mgmt/instances/models.py b/trove/extensions/mgmt/instances/models.py
index 9766d973..3b1d9dc6 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
@@ -219,8 +220,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)