(feat): Added rescue block in pod-delete by powerseal lib (#1085)

Signed-off-by: shubhamchaudhary <shubham.chaudhary@mayadata.io>

Co-authored-by: Amit Bhatt <33670159+amitbhatt818@users.noreply.github.com>
This commit is contained in:
Shubham Chaudhary 2020-01-09 17:02:26 +05:30 committed by Chandan Kumar
parent a0b92ea50d
commit 2ec1f03f53
1 changed files with 67 additions and 39 deletions

View File

@ -1,3 +1,5 @@
- block:
- name: Generate the powerfulseal deployment spec from template
template:
src: /chaoslib/powerfulseal/powerfulseal.j2
@ -8,8 +10,8 @@
kubectl apply -f powerfulseal.yml -n {{ a_ns }}
args:
executable: /bin/bash
register: result
failed_when: "result.rc != 0"
register: deployment_result
failed_when: "deployment_result.rc != 0"
- name: Confirm that powerfulseal pod is running
shell: >
@ -33,12 +35,38 @@
failed_when: "result.rc != 0"
- name: Confirm that powerfulseal pod is cleaned up
shell: >
kubectl get pod -l name=powerfulseal --no-headers -n {{ a_ns }}
args:
executable: /bin/bash
register: result
until: "'Running' not in result.stdout"
k8s_facts:
kind: Deployment
label_selectors:
- name=powerfulseal
register: resource_deployment
until: "resource_deployment.resources | length < 1"
delay: 1
retries: 120
rescue:
- block:
- name: Tear down the powerfulseal deployment
shell: >
kubectl delete -f powerfulseal.yml -n {{ a_ns }}
args:
executable: /bin/bash
when: deployment_result.rc == 0
- name: Confirm that powerfulseal pod is cleaned up
k8s_facts:
kind: Deployment
label_selectors:
- name=powerfulseal
register: resource_deployment
until: "resource_deployment.resources | length < 1"
delay: 1
retries: 120
when: "deployment_result is defined"
- fail:
msg: "pod_failure_by_powerfulseal lib failed"
when: true