(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:
parent
a0b92ea50d
commit
2ec1f03f53
|
|
@ -1,17 +1,19 @@
|
|||
- name: Generate the powerfulseal deployment spec from template
|
||||
- block:
|
||||
|
||||
- name: Generate the powerfulseal deployment spec from template
|
||||
template:
|
||||
src: /chaoslib/powerfulseal/powerfulseal.j2
|
||||
dest: powerfulseal.yml
|
||||
|
||||
- name: Setup powerfulseal to initiate random pod chaos
|
||||
- name: Setup powerfulseal to initiate random pod chaos
|
||||
shell:
|
||||
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
|
||||
- name: Confirm that powerfulseal pod is running
|
||||
shell: >
|
||||
kubectl get pod -l name=powerfulseal --no-headers -n {{ a_ns }}
|
||||
args:
|
||||
|
|
@ -21,10 +23,10 @@
|
|||
delay: 1
|
||||
retries: 90
|
||||
|
||||
- name: Wait for chaos duration
|
||||
- name: Wait for chaos duration
|
||||
wait_for: timeout={{ c_duration }}
|
||||
|
||||
- name: Tear down the powerfulseal deployment
|
||||
- name: Tear down the powerfulseal deployment
|
||||
shell:
|
||||
kubectl delete -f powerfulseal.yml -n {{ a_ns }}
|
||||
args:
|
||||
|
|
@ -32,13 +34,39 @@
|
|||
register: result
|
||||
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"
|
||||
- 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
|
||||
|
||||
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
|
||||
|
|
|
|||
Loading…
Reference in New Issue