]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
heat workaround for HA/Autoscaling regression
authorSteven Hardy <shardy@redhat.com>
Thu, 15 Nov 2012 10:03:46 +0000 (10:03 +0000)
committerSteven Hardy <shardy@redhat.com>
Thu, 15 Nov 2012 10:52:16 +0000 (10:52 +0000)
Interim workaround for HA/Autoscaling regression, caused by change of
scope for stack_get_by_name to be per-tenant, meaning we need to do a
brute-force lookup to find the stack entry when using the stored admin
context.

A better, more comprehensive (but more intrusive) fix is in-progress
but this at least returns us to the same functionality we had before

Note this means that all stacks using WatchRule still need to have names
unique accross all tenants.

bug 1078779

Change-Id: Iad1830d38262d1afb63cee16a3e366d9fd09acb4
Signed-off-by: Steven Hardy <shardy@redhat.com>
heat/engine/watchrule.py

index 3a5854ad39f5e7e8576d2a6b851b4ef9e84ffd65..69b86fa59df5f37d5cd31406e336ac958787e48e 100644 (file)
@@ -228,7 +228,24 @@ class WatchRule(object):
                         new_state)
             actioned = True
         else:
-            s = db_api.stack_get_by_name(self.context, self.stack_name)
+            # FIXME : hack workaround for new stack_get_by_name tenant
+            # scoping, this is the simplest possible solution to the
+            # HA/Autoscaling regression described in bug/1078779
+            # Further work in-progress here (shardy) as this
+            # breaks when stack_name is not unique accross tenants
+            sl = [x for x in
+                  db_api.stack_get_all(self.context)
+                  if x.name == self.stack_name]
+            s = None
+            if len(sl) == 1:
+                s = sl[0]
+            elif len(sl) > 1:
+                logger.error("stack %s name not unique, " % self.stack_name
+                             + "cannot action watch rule")
+            else:
+                logger.error("stack %s name could not be found, " %
+                             self.stack_name + "cannot action watch rule")
+
             if s and s.status in (parser.Stack.CREATE_COMPLETE,
                                   parser.Stack.UPDATE_COMPLETE):
                 user_creds = db_api.user_creds_get(s.user_creds_id)