diff --git a/watcher/common/exception.py b/watcher/common/exception.py index 47402b823..00e5fdb27 100644 --- a/watcher/common/exception.py +++ b/watcher/common/exception.py @@ -340,6 +340,10 @@ class MetricCollectorNotDefined(WatcherException): msg_fmt = _("The metrics resource collector is not defined") +class ClusterStateStale(WatcherException): + msg_fmt = _("The cluster state is stale") + + class ClusterDataModelCollectionError(WatcherException): msg_fmt = _("The cluster data model '%(cdm)s' could not be built") diff --git a/watcher/decision_engine/strategy/strategies/base.py b/watcher/decision_engine/strategy/strategies/base.py index b1b552ac2..13c241032 100644 --- a/watcher/decision_engine/strategy/strategies/base.py +++ b/watcher/decision_engine/strategy/strategies/base.py @@ -185,6 +185,9 @@ class BaseStrategy(loadable.Loadable): if not self._compute_model: raise exception.ClusterStateNotDefined() + if self._compute_model.stale: + raise exception.ClusterStateStale() + return self._compute_model @classmethod diff --git a/watcher/decision_engine/strategy/strategies/basic_consolidation.py b/watcher/decision_engine/strategy/strategies/basic_consolidation.py index e51815ded..99df9b96a 100644 --- a/watcher/decision_engine/strategy/strategies/basic_consolidation.py +++ b/watcher/decision_engine/strategy/strategies/basic_consolidation.py @@ -384,12 +384,16 @@ class BasicConsolidation(base.ServerConsolidationBaseStrategy): def pre_execute(self): LOG.info(_LI("Initializing Server Consolidation")) + if not self.compute_model: raise exception.ClusterStateNotDefined() if len(self.compute_model.get_all_compute_nodes()) == 0: raise exception.ClusterEmpty() + if self.compute_model.stale: + raise exception.ClusterStateStale() + LOG.debug(self.compute_model.to_string()) def do_execute(self): diff --git a/watcher/decision_engine/strategy/strategies/outlet_temp_control.py b/watcher/decision_engine/strategy/strategies/outlet_temp_control.py index 5af3627ea..539743445 100644 --- a/watcher/decision_engine/strategy/strategies/outlet_temp_control.py +++ b/watcher/decision_engine/strategy/strategies/outlet_temp_control.py @@ -230,6 +230,9 @@ class OutletTempControl(base.ThermalOptimizationBaseStrategy): if not self.compute_model: raise wexc.ClusterStateNotDefined() + if self.compute_model.stale: + raise wexc.ClusterStateStale() + LOG.debug(self.compute_model.to_string()) def do_execute(self): diff --git a/watcher/decision_engine/strategy/strategies/uniform_airflow.py b/watcher/decision_engine/strategy/strategies/uniform_airflow.py index c1aacebbb..4a67bee1f 100644 --- a/watcher/decision_engine/strategy/strategies/uniform_airflow.py +++ b/watcher/decision_engine/strategy/strategies/uniform_airflow.py @@ -293,6 +293,9 @@ class UniformAirflow(base.BaseStrategy): if not self.compute_model: raise wexc.ClusterStateNotDefined() + if self.compute_model.stale: + raise wexc.ClusterStateStale() + LOG.debug(self.compute_model.to_string()) def do_execute(self): diff --git a/watcher/decision_engine/strategy/strategies/vm_workload_consolidation.py b/watcher/decision_engine/strategy/strategies/vm_workload_consolidation.py index 411b6cb9e..ae3fa3d6a 100644 --- a/watcher/decision_engine/strategy/strategies/vm_workload_consolidation.py +++ b/watcher/decision_engine/strategy/strategies/vm_workload_consolidation.py @@ -487,6 +487,9 @@ class VMWorkloadConsolidation(base.ServerConsolidationBaseStrategy): if not self.compute_model: raise exception.ClusterStateNotDefined() + if self.compute_model.stale: + raise exception.ClusterStateStale() + LOG.debug(self.compute_model.to_string()) def do_execute(self): diff --git a/watcher/decision_engine/strategy/strategies/workload_balance.py b/watcher/decision_engine/strategy/strategies/workload_balance.py index 5dba465b9..a54d9af6a 100644 --- a/watcher/decision_engine/strategy/strategies/workload_balance.py +++ b/watcher/decision_engine/strategy/strategies/workload_balance.py @@ -283,6 +283,9 @@ class WorkloadBalance(base.WorkloadStabilizationBaseStrategy): if not self.compute_model: raise wexc.ClusterStateNotDefined() + if self.compute_model.stale: + raise wexc.ClusterStateStale() + LOG.debug(self.compute_model.to_string()) def do_execute(self): diff --git a/watcher/decision_engine/strategy/strategies/workload_stabilization.py b/watcher/decision_engine/strategy/strategies/workload_stabilization.py index 957d1142e..ada3f3d5d 100644 --- a/watcher/decision_engine/strategy/strategies/workload_stabilization.py +++ b/watcher/decision_engine/strategy/strategies/workload_stabilization.py @@ -420,6 +420,9 @@ class WorkloadStabilization(base.WorkloadStabilizationBaseStrategy): if not self.compute_model: raise exception.ClusterStateNotDefined() + if self.compute_model.stale: + raise exception.ClusterStateStale() + self.weights = self.input_parameters.weights self.metrics = self.input_parameters.metrics self.thresholds = self.input_parameters.thresholds