working on powerfulseal retry logic

This commit is contained in:
prubenda
2020-08-18 09:16:44 -04:00
parent 31f06b861a
commit 8f5b688fba
7 changed files with 57 additions and 7 deletions

View File

@@ -1,13 +1,11 @@
kraken:
kubeconfig_path: /root/.kube/config # Path to kubeconfig
exit_on_failure: False # Exit when a post action scenario fails
scenarios: # List of policies/chaos scenarios to load
- - scenarios/etcd.yml
- scenarios/post_action_etcd_example.sh
- - scenarios/openshift-kube-apiserver.yml
- scenarios/post_action_openshift-kube-apiserver.yml
- - scenarios/openshift-apiserver.yml
- scenarios/post_action_openshift-apiserver.yml
- - scenarios/regex_openshift_pod_kill.yml
- scenarios/post_action_regex.py
node_scenarios: # List of chaos node scenarios to load
@@ -20,4 +18,4 @@ cerberus:
tunings:
wait_duration: 60 # Duration to wait between each chaos scenario
iterations: 1 # Number of times to execute the scenarios
daemon_mode: False # Iterations are set to infinity which means that the cerberus will monitor the resources forever
daemon_mode: False # Iterations are set to infinity which means that the cerberus will monitor the resources forever

View File

@@ -1,5 +1,5 @@
datetime
pyfiglet
powerfulseal==3.0.0rc11
git+https://github.com/powerfulseal/powerfulseal.git
requests
boto3

View File

@@ -119,7 +119,7 @@ def run_post_action(kubeconfig_path, scenario, pre_action_output=""):
else:
logging.info(scenario + ' post action response did not match pre check output')
return False
else:
elif scenario != "":
# invoke custom bash script
action_output = runcommand.invoke(scenario).strip()
if pre_action_output:
@@ -208,7 +208,11 @@ def main(cfg):
try:
# Loop to run the scenarios starts here
for scenario in scenarios:
pre_action_output = run_post_action(kubeconfig_path, scenario[1])
if len(scenario) > 1:
pre_action_output = run_post_action(kubeconfig_path, scenario[1])
else:
pre_action_output = ''
runcommand.invoke("powerfulseal autonomous --use-pod-delete-instead-of-ssh-kill" # noqa
" --policy-file %s --kubeconfig %s --no-cloud"
" --inventory-kubernetes --headless"
@@ -217,6 +221,7 @@ def main(cfg):
logging.info("Scenario: %s has been successfully injected!" % (scenario[0]))
logging.info("Waiting for the specified duration: %s" % (wait_duration))
time.sleep(wait_duration)
failed_post_scenarios = post_actions(kubeconfig_path, scenario,
failed_post_scenarios,
pre_action_output)

View File

@@ -18,3 +18,15 @@ scenarios:
- kill:
probability: 1
force: true
- podAction:
matches:
- labels:
namespace: "openshift-etcd"
selector: "k8s-app=etcd"
retries:
retriesTimeout:
timeout: 180
actions:
- checkPodCount:
count: 3

View File

@@ -21,3 +21,15 @@ scenarios:
- kill:
probability: 1
force: true
- podAction:
matches:
- labels:
namespace: "openshift-apiserver"
selector: "app=openshift-apiserver"
retries:
retriesTimeout:
timeout: 180
actions:
- checkPodCount:
count: 3

View File

@@ -20,3 +20,14 @@ scenarios:
- kill:
probability: 1
force: true
- podAction:
matches:
- labels:
namespace: "openshift-kube-apiserver"
selector: "app=openshift-kube-apiserver"
retries:
retriesTimeout:
timeout: 180
actions:
- checkPodCount:
count: 3

View File

@@ -21,3 +21,15 @@ scenarios:
- kill:
probability: 1
force: true
- podAction:
matches:
- labels:
namespace: "openshift-monitoring"
selector: "app=prometheus"
retries:
retriesTimeout:
timeout: 180
actions:
- checkPodCount:
count: 2