From a9ef9f3a94d341658a1add27fac78e44325a50f9 Mon Sep 17 00:00:00 2001
From: licanwei
Date: Thu, 8 Dec 2016 13:34:03 +0800
Subject: [PATCH] update strategy table when parameters_spec changes
At present, In the sync function, there is no check about the
parameters_spec field in strategy table, if the parameters_spec
field content has changed, Such as increased 'periods' parameter,
strategy table will not be updated, the program will run abnormal.
exception msg:
2016-12-05 11:11:39.138 TRACE watcher.decision_engine.audit.base
raise AttributeError(name)
2016-12-05 11:11:39.138 TRACE watcher.decision_engine.audit.base
AttributeError: periods
Change-Id: I84709c246acbdf44ccac257b07a74084962bb628
Closes-Bug: #1647521
---
watcher/decision_engine/sync.py | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/watcher/decision_engine/sync.py b/watcher/decision_engine/sync.py
index 48e189e9b..371433d86 100644
--- a/watcher/decision_engine/sync.py
+++ b/watcher/decision_engine/sync.py
@@ -14,6 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
+import ast
import collections
from oslo_log import log
@@ -536,11 +537,14 @@ class Syncer(object):
def _soft_delete_stale_strategies(self, strategy_map, matching_strategies):
strategy_name = strategy_map.name
strategy_display_name = strategy_map.display_name
+ parameters_spec = strategy_map.parameters_spec
stale_strategies = []
for matching_strategy in matching_strategies:
if (matching_strategy.display_name == strategy_display_name and
- matching_strategy.goal_id not in self.goal_mapping):
+ matching_strategy.goal_id not in self.goal_mapping and
+ matching_strategy.parameters_spec ==
+ ast.literal_eval(parameters_spec)):
LOG.info(_LI("Strategy %s unchanged"), strategy_name)
else:
LOG.info(_LI("Strategy %s modified"), strategy_name)