summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2015-04-02 02:23:20 +0000
committerGerrit Code Review <review@openstack.org>2015-04-02 02:23:20 +0000
commitbc13a53d40c422b9a4ad552a873f01ea5633abe2 (patch)
tree590f59d45307623f5e2a01495da93e0be3eea67c
parent00d29e852985bc203cb8380d93011e591e20b28a (diff)
parent80f898d3ba16d5c644447dbacf3a1bad6eaa6488 (diff)
downloadtrove-bc13a53d40c422b9a4ad552a873f01ea5633abe2.tar.gz
Merge "Fixed NotificationTransformer to handle missing InstanceServiceStatus"
-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 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)