Skip to content

Commit c43ac26

Browse files
authored
(feat): Adding openebs control plane pod delete experiment (#1203)
Signed-off-by: Raj <[email protected]>
1 parent 6a20d23 commit c43ac26

7 files changed

+185
-0
lines changed

chaoslib/litmus/kill_random_pod.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
- block:
2+
23
- name: Get a list of all pods from given namespace
34
k8s_facts:
45
kind: Pod
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{% if c_lib is defined and c_lib == 'powerfulseal' %}
2+
c_util: /chaoslib/powerfulseal/pod_failure_by_powerfulseal.yml
3+
{% else %}
4+
c_util: /chaoslib/litmus/kill_random_pod.yml
5+
{% endif %}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
- hosts: localhost
2+
connection: local
3+
4+
vars:
5+
c_experiment: "openebs-control-plane-pod-delete"
6+
c_duration: "{{ lookup('env','TOTAL_CHAOS_DURATION') }}"
7+
c_interval: "{{ lookup('env','CHAOS_INTERVAL') }}"
8+
ramp_time: "{{ lookup('env','RAMP_TIME') }}"
9+
c_force: "{{ lookup('env','FORCE') }}"
10+
c_lib: "{{ lookup('env','LIB') }}"
11+
c_svc_acc: "{{ lookup('env','CHAOS_SERVICE_ACCOUNT') }}"
12+
openebs_ns: "{{ lookup('env','OPENEBS_NAMESPACE') }}"
13+
kill_count: "{{ lookup('env','KILL_COUNT') }}"
14+
15+
tasks:
16+
- block:
17+
- include: openebs_control_plane_pod_delete_ansible_prerequisites.yml
18+
19+
- include_vars:
20+
file: chaosutil.yml
21+
22+
- name: Include openebs control plane components
23+
include_vars:
24+
file: /experiments/openebs/openebs_control_plane_components.yml
25+
name: openebs
26+
27+
## GENERATE EXP RESULT NAME
28+
- block:
29+
30+
- name: Construct chaos result name (experiment_name)
31+
set_fact:
32+
c_experiment: "{{ lookup('env','CHAOSENGINE') }}-{{ c_experiment }}"
33+
34+
when: lookup('env','CHAOSENGINE')
35+
36+
## RECORD START-OF-EXPERIMENT IN LITMUSCHAOS RESULT CR
37+
- include_tasks: /utils/runtime/update_chaos_result_resource.yml
38+
vars:
39+
status: 'SOT'
40+
namespace: "{{ openebs_ns }}"
41+
42+
## INJECT CHAOS ON CONTROL PLANE COMPONENTS
43+
- name: Including main components
44+
include_tasks: openebs_control_plane_pod_delete_internal_tasks.yml
45+
loop: "{{ openebs.components }}"
46+
47+
- set_fact:
48+
flag: "Pass"
49+
50+
rescue:
51+
- set_fact:
52+
flag: "Fail"
53+
54+
always:
55+
## RECORD END-OF-TEST IN LITMUSCHAOS RESULT CR
56+
- include_tasks: /utils/runtime/update_chaos_result_resource.yml
57+
vars:
58+
status: 'EOT'
59+
namespace: "{{ openebs_ns }}"
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
- name: Identify the chaos util to be invoked
2+
template:
3+
src: chaosutil.j2
4+
dest: chaosutil.yml
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
## PRE-CHAOS APPLICATION LIVENESS CHECK
2+
- name: Verify that the AUT (Application Under Test) is running
3+
include_tasks: "/utils/common/status_app_pod.yml"
4+
vars:
5+
app_ns: "{{ item.namespace }}"
6+
app_label: "{{ item.labels[0] }}"
7+
delay: 1
8+
retries: 60
9+
10+
## FAULT INJECTION
11+
- include_tasks: "{{ c_util }}"
12+
vars:
13+
app_ns: "{{ item.namespace }}"
14+
app_label: "{{ item.labels[0] }}"
15+
c_interval: 5
16+
17+
## POST-CHAOS APPLICATION LIVENESS CHECK
18+
- name: Verify AUT liveness post fault-injection
19+
include_tasks: "/utils/common/status_app_pod.yml"
20+
vars:
21+
app_ns: "{{ item.namespace }}"
22+
app_label: "{{ item.labels[0] }}"
23+
delay: 1
24+
retries: 60
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
---
2+
apiVersion: batch/v1
3+
kind: Job
4+
metadata:
5+
generateName: openebs-control-plane-pod-delete-
6+
spec:
7+
template:
8+
metadata:
9+
labels:
10+
experiment: openebs-control-plane-pod-delete
11+
spec:
12+
# Placeholder that is updated by the executor for automated runs
13+
# Provide appropriate SA (with desired permissions) if executed manually
14+
serviceAccountName: %CHAOS_SERVICE_ACCOUNT%
15+
restartPolicy: Never
16+
containers:
17+
- name: ansibletest
18+
image: litmuschaos/ansible-runner:ci
19+
imagePullPolicy: Always
20+
env:
21+
- name: ANSIBLE_STDOUT_CALLBACK
22+
value: 'default'
23+
24+
# provide openebs namespace
25+
- name: OPENEBS_NAMESPACE
26+
value: 'openebs'
27+
28+
## Period to wait before injection of chaos
29+
- name: RAMP_TIME
30+
value: '6'
31+
32+
- name: FORCE
33+
value: ''
34+
35+
## env var that describes the library used to execute the chaos
36+
## default: litmus. Supported values: litmus, powerfulseal
37+
- name: LIB
38+
value: ''
39+
40+
- name: CHAOSENGINE
41+
value: ''
42+
43+
- name: CHAOS_SERVICE_ACCOUNT
44+
valueFrom:
45+
fieldRef:
46+
fieldPath: spec.serviceAccountName
47+
48+
command: ["/bin/bash"]
49+
args: ["-c", "ansible-playbook ./experiments/openebs/openebs-control-plane-pod-delete/openebs_control_plane_pod_delete_ansible_logic.yml -i /etc/ansible/hosts -vv; exit 0"]
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
version: 1.6.0
2+
components:
3+
- name: maya-apiserver
4+
kind: Deployment
5+
namespace: openebs
6+
labels:
7+
- openebs.io/component-name=maya-apiserver
8+
9+
- name: openebs-admission-server
10+
kind: Deployment
11+
namespace: openebs
12+
labels:
13+
- openebs.io/component-name=admission-webhook
14+
15+
- name: openebs-localpv-provisioner
16+
kind: Deployment
17+
namespace: openebs
18+
labels:
19+
- openebs.io/component-name=openebs-localpv-provisioner
20+
21+
- name: openebs-ndm-operator
22+
kind: Deployment
23+
namespace: openebs
24+
labels:
25+
- openebs.io/component-name=ndm-operator
26+
27+
- name: openebs-provisioner
28+
kind: Deployment
29+
namespace: openebs
30+
labels:
31+
- openebs.io/component-name=openebs-provisioner
32+
33+
- name: openebs-snapshot-operator
34+
kind: Deployment
35+
namespace: openebs
36+
labels:
37+
- openebs.io/component-name=openebs-snapshot-operator
38+
39+
- name: openebs-ndm
40+
kind: DaemonSet
41+
namespace: openebs
42+
labels:
43+
- openebs.io/component-name=ndm

0 commit comments

Comments
 (0)