Reload policy after each run
@@ -55,15 +55,18 @@ class PolicyRunner():
return True
@classmethod
- def run(cls, policy, inventory, k8s_inventory, driver, executor,
+ def run(cls, policy_loader, inventory, k8s_inventory, driver, executor,
metric_collector=None):
""" Runs a policy forever
"""
+ policy = policy_loader()
+ loops = policy.get("config", {}).get("runStrategy", {}).get("runs", None)
+ while loops is None or loops > 0:
+ policy = policy_loader()
config = policy.get("config", {}).get("runStrategy", {})
should_randomize = config.get("strategy") == "random"
wait_min = config.get("minSecondsBetweenRuns", 0)
wait_max = config.get("maxSecondsBetweenRuns", 300)
- loops = config.get("runs", None)
exitConfig = policy.get("config", {}).get("exitStrategy", {})
exitStrategy = exitConfig.get("strategy", "report")
scenarios = [
@@ -78,7 +81,7 @@ class PolicyRunner():
)
for item in policy.get("scenarios", [])
]
- while loops is None or loops > 0:
+
if not scenarios:
return True
if should_randomize:
