Skip to content

Commit

Permalink
(feat): Adding openebs control plane pod delete experiment (#1203)
Browse files Browse the repository at this point in the history
Signed-off-by: Raj <raj.das@mayadata.io>
  • Loading branch information
imrajdas committed Feb 12, 2020
1 parent 6a20d23 commit c43ac26
Show file tree
Hide file tree
Showing 7 changed files with 185 additions and 0 deletions.
1 change: 1 addition & 0 deletions chaoslib/litmus/kill_random_pod.yml
@@ -1,4 +1,5 @@
- block:

- name: Get a list of all pods from given namespace
k8s_facts:
kind: Pod
Expand Down
@@ -0,0 +1,5 @@
{% if c_lib is defined and c_lib == 'powerfulseal' %}
c_util: /chaoslib/powerfulseal/pod_failure_by_powerfulseal.yml
{% else %}
c_util: /chaoslib/litmus/kill_random_pod.yml
{% endif %}
@@ -0,0 +1,59 @@
- hosts: localhost
connection: local

vars:
c_experiment: "openebs-control-plane-pod-delete"
c_duration: "{{ lookup('env','TOTAL_CHAOS_DURATION') }}"
c_interval: "{{ lookup('env','CHAOS_INTERVAL') }}"
ramp_time: "{{ lookup('env','RAMP_TIME') }}"
c_force: "{{ lookup('env','FORCE') }}"
c_lib: "{{ lookup('env','LIB') }}"
c_svc_acc: "{{ lookup('env','CHAOS_SERVICE_ACCOUNT') }}"
openebs_ns: "{{ lookup('env','OPENEBS_NAMESPACE') }}"
kill_count: "{{ lookup('env','KILL_COUNT') }}"

tasks:
- block:
- include: openebs_control_plane_pod_delete_ansible_prerequisites.yml

- include_vars:
file: chaosutil.yml

- name: Include openebs control plane components
include_vars:
file: /experiments/openebs/openebs_control_plane_components.yml
name: openebs

## GENERATE EXP RESULT NAME
- block:

- name: Construct chaos result name (experiment_name)
set_fact:
c_experiment: "{{ lookup('env','CHAOSENGINE') }}-{{ c_experiment }}"

when: lookup('env','CHAOSENGINE')

## RECORD START-OF-EXPERIMENT IN LITMUSCHAOS RESULT CR
- include_tasks: /utils/runtime/update_chaos_result_resource.yml
vars:
status: 'SOT'
namespace: "{{ openebs_ns }}"

## INJECT CHAOS ON CONTROL PLANE COMPONENTS
- name: Including main components
include_tasks: openebs_control_plane_pod_delete_internal_tasks.yml
loop: "{{ openebs.components }}"

- set_fact:
flag: "Pass"

rescue:
- set_fact:
flag: "Fail"

always:
## RECORD END-OF-TEST IN LITMUSCHAOS RESULT CR
- include_tasks: /utils/runtime/update_chaos_result_resource.yml
vars:
status: 'EOT'
namespace: "{{ openebs_ns }}"
@@ -0,0 +1,4 @@
- name: Identify the chaos util to be invoked
template:
src: chaosutil.j2
dest: chaosutil.yml
@@ -0,0 +1,24 @@
## PRE-CHAOS APPLICATION LIVENESS CHECK
- name: Verify that the AUT (Application Under Test) is running
include_tasks: "/utils/common/status_app_pod.yml"
vars:
app_ns: "{{ item.namespace }}"
app_label: "{{ item.labels[0] }}"
delay: 1
retries: 60

## FAULT INJECTION
- include_tasks: "{{ c_util }}"
vars:
app_ns: "{{ item.namespace }}"
app_label: "{{ item.labels[0] }}"
c_interval: 5

## POST-CHAOS APPLICATION LIVENESS CHECK
- name: Verify AUT liveness post fault-injection
include_tasks: "/utils/common/status_app_pod.yml"
vars:
app_ns: "{{ item.namespace }}"
app_label: "{{ item.labels[0] }}"
delay: 1
retries: 60
@@ -0,0 +1,49 @@
---
apiVersion: batch/v1
kind: Job
metadata:
generateName: openebs-control-plane-pod-delete-
spec:
template:
metadata:
labels:
experiment: openebs-control-plane-pod-delete
spec:
# Placeholder that is updated by the executor for automated runs
# Provide appropriate SA (with desired permissions) if executed manually
serviceAccountName: %CHAOS_SERVICE_ACCOUNT%
restartPolicy: Never
containers:
- name: ansibletest
image: litmuschaos/ansible-runner:ci
imagePullPolicy: Always
env:
- name: ANSIBLE_STDOUT_CALLBACK
value: 'default'

# provide openebs namespace
- name: OPENEBS_NAMESPACE
value: 'openebs'

## Period to wait before injection of chaos
- name: RAMP_TIME
value: '6'

- name: FORCE
value: ''

## env var that describes the library used to execute the chaos
## default: litmus. Supported values: litmus, powerfulseal
- name: LIB
value: ''

- name: CHAOSENGINE
value: ''

- name: CHAOS_SERVICE_ACCOUNT
valueFrom:
fieldRef:
fieldPath: spec.serviceAccountName

command: ["/bin/bash"]
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"]
43 changes: 43 additions & 0 deletions experiments/openebs/openebs_control_plane_components.yml
@@ -0,0 +1,43 @@
version: 1.6.0
components:
- name: maya-apiserver
kind: Deployment
namespace: openebs
labels:
- openebs.io/component-name=maya-apiserver

- name: openebs-admission-server
kind: Deployment
namespace: openebs
labels:
- openebs.io/component-name=admission-webhook

- name: openebs-localpv-provisioner
kind: Deployment
namespace: openebs
labels:
- openebs.io/component-name=openebs-localpv-provisioner

- name: openebs-ndm-operator
kind: Deployment
namespace: openebs
labels:
- openebs.io/component-name=ndm-operator

- name: openebs-provisioner
kind: Deployment
namespace: openebs
labels:
- openebs.io/component-name=openebs-provisioner

- name: openebs-snapshot-operator
kind: Deployment
namespace: openebs
labels:
- openebs.io/component-name=openebs-snapshot-operator

- name: openebs-ndm
kind: DaemonSet
namespace: openebs
labels:
- openebs.io/component-name=ndm

0 comments on commit c43ac26

Please sign in to comment.