Skip to content

Commit

Permalink
Merge pull request #1101 from ksatchit/v1.0.x-RC2-Clone
Browse files Browse the repository at this point in the history
[Cherry Pick for RC2]
  • Loading branch information
Chandan Kumar committed Jan 10, 2020
2 parents 1d4630c + 90dfbea commit bf8104e
Show file tree
Hide file tree
Showing 15 changed files with 138 additions and 99 deletions.
9 changes: 9 additions & 0 deletions .bettercodehub.yml
@@ -0,0 +1,9 @@
component_depth: 2
languages:
- go
exclude:
- /build/plugins/.*
- /build/utils/.*
test:
include:
- /contribute/developer_guide/test_*\.py
2 changes: 2 additions & 0 deletions ADOPTERS.md
@@ -0,0 +1,2 @@
This is the list of organizations and users that publicly shared details of how they are using LitmusChaos for running chaos experiments.
Please send PRs to add or remove organizations/users.
2 changes: 2 additions & 0 deletions README.md
Expand Up @@ -9,6 +9,7 @@
[![Twitter Follow](https://img.shields.io/twitter/follow/litmuschaos?style=social)](https://twitter.com/LitmusChaos)
[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/3202/badge)](https://bestpractices.coreinfrastructure.org/projects/3202)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=litmuschaos_litmus&metric=alert_status)](https://sonarcloud.io/dashboard?id=litmuschaos_litmus)
[![BCH compliance](https://bettercodehub.com/edge/badge/litmuschaos/litmus?branch=master)](https://bettercodehub.com/)
<br><br><br><br>


Expand Down Expand Up @@ -42,6 +43,7 @@ See <a href="https://docs.litmuschaos.io/docs/next/getstarted.html" target="_bla
See <a href="https://github.com/litmuschaos/community-charts/blob/master/CONTRIBUTING.md" target="_blank">Contributing to chaos hub</a>

## Adopters
See <a href="https://github.com/litmuschaos/litmus/blob/master/ADOPTERS.md" target="_blank">Adopters of LitmusChaos</a>


(*Send a PR to the above page if you are using Litmus in your chaos engineering practice*)
Expand Down
2 changes: 1 addition & 1 deletion chaoslib/chaoskube/README.md
@@ -1,3 +1,3 @@
## Note

The chaoskube library is not supported by litmuschaos any more. It will be left here, because it can be used if the chaosServiceAccount has cluster-scope. As of version 0.8 chaosexperiments are namespace-scoped
The chaoskube library is not supported by litmuschaos any more. It will be left here, because it can be used if the chaosServiceAccount has cluster-scope. As of version 1.0 the pod-delete (and other app-level) chaosexperiments are namespace-scoped
2 changes: 1 addition & 1 deletion chaoslib/litmus/cpu_hog/pod_cpu_hog.yml
Expand Up @@ -16,7 +16,7 @@
set_fact:
app_pod: "{{ app_pod_name.stdout }}"

when: "app_pod is not defined or app_pod = ''"
when: "app_pod is not defined or app_pod == ''"

# here app_ns is the namespace of pod on which we are performing cpu chaos
# in genric experiments app_ns is same as app_ns
Expand Down
28 changes: 14 additions & 14 deletions chaoslib/litmus/disk_fill/disk_fill_by_litmus.yml
Expand Up @@ -151,35 +151,35 @@
executable: /bin/bash

- name: Confirm that the Disk Fill DaemonSet is deleted successfully
shell: >
kubectl get ds -l app=disk-fill --no-headers
args:
executable: /bin/bash
register: result
until: "'No resources found' in result.stderr"
k8s_facts:
kind: DaemonSet
label_selectors:
- app=disk-fill
register: resource_daemonset
until: "resource_daemonset.resources | length < 1"
delay: 5
retries: 60

rescue:

- block:

- name: Deleting the Cpu Hog DaemonSet
- name: Deleting the Disk-fill DaemonSet
shell: >
kubectl delete -f /chaoslib/litmus/disk_fill/disk_fill_ds.yaml -n {{ a_ns }}
args:
executable: /bin/bash
when: "disk_fill_ds_result.rc == 0 "

- name: Confirm that the Disk Fill DaemonSet is deleted successfully
shell: >
kubectl get ds -l app=disk-fill --no-headers
args:
executable: /bin/bash
register: result
until: "'No resources found' in result.stderr"
k8s_facts:
kind: DaemonSet
label_selectors:
- app=disk-fill
register: resource_daemonset
until: "resource_daemonset.resources | length < 1"
delay: 5
retries: 60
retries: 60
when: "disk_fill_ds_result is defined"

- fail:
Expand Down
24 changes: 12 additions & 12 deletions chaoslib/litmus/platform/gke/pod_cpu_consumption.yml
Expand Up @@ -86,12 +86,12 @@
executable: /bin/bash

- name: Confirm that the Cpu Hog DaemonSet is deleted successfully
shell: >
kubectl get ds -l app=cpu-hog --no-headers
args:
executable: /bin/bash
register: result
until: "'No resources found' in result.stderr"
k8s_facts:
kind: DaemonSet
label_selectors:
- app=cpu-hog
register: resource_daemonset
until: "resource_daemonset.resources | length < 1"
delay: 5
retries: 60

Expand All @@ -107,12 +107,12 @@
when: "cpu_hog_ds_result is succeeded"

- name: Confirm that the Cpu Hog DaemonSet is deleted successfully
shell: >
kubectl get ds -l app=cpu-hog --no-headers
args:
executable: /bin/bash
register: result
until: "'No resources found' in result.stderr"
k8s_facts:
kind: DaemonSet
label_selectors:
- app=cpu-hog
register: resource_daemonset
until: "resource_daemonset.resources | length < 1"
delay: 5
retries: 60
when: "cpu_hog_ds_result is defined"
Expand Down
114 changes: 71 additions & 43 deletions chaoslib/powerfulseal/pod_failure_by_powerfulseal.yml
@@ -1,44 +1,72 @@
- 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
shell:
kubectl apply -f powerfulseal.yml -n {{ a_ns }}
args:
executable: /bin/bash
register: result
failed_when: "result.rc != 0"

- name: Confirm that powerfulseal pod is running
shell: >
kubectl get pod -l name=powerfulseal --no-headers -n {{ a_ns }}
args:
executable: /bin/bash
register: result
until: "'Running' in result.stdout"
delay: 1
retries: 90

- name: Wait for chaos duration
wait_for: timeout={{ c_duration }}

- name: Tear down the powerfulseal deployment
shell:
kubectl delete -f powerfulseal.yml -n {{ a_ns }}
args:
executable: /bin/bash
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"
delay: 1
retries: 120
- 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
shell:
kubectl apply -f powerfulseal.yml -n {{ app_ns }}
args:
executable: /bin/bash
register: deployment_result
failed_when: "deployment_result.rc != 0"

- name: Confirm that powerfulseal pod is running
shell: >
kubectl get pod -l name=powerfulseal --no-headers -n {{ app_ns }}
args:
executable: /bin/bash
register: result
until: "'Running' in result.stdout"
delay: 1
retries: 90

- name: Wait for chaos duration
wait_for: timeout={{ c_duration }}

- name: Tear down the powerfulseal deployment
shell:
kubectl delete -f powerfulseal.yml -n {{ app_ns }}
args:
executable: /bin/bash
register: result
failed_when: "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

rescue:

- block:

- name: Tear down the powerfulseal deployment
shell: >
kubectl delete -f powerfulseal.yml -n {{ app_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
4 changes: 2 additions & 2 deletions chaoslib/powerfulseal/powerfulseal.j2
Expand Up @@ -13,8 +13,8 @@ data:
- name: "delete random pods in default namespace"
match:
- labels:
namespace: {{ a_ns }}
selector: {{ a_label }}
namespace: {{ app_ns }}
selector: {{ app_label }}
filters:
- randomSample:
size: 1
Expand Down
4 changes: 0 additions & 4 deletions executor/README.md
Expand Up @@ -127,12 +127,8 @@

### Limitations

- Executor is currently unable to parse more than one configmap.

- The name of file which contains data for configmap in experimentCR should be parameters.yml

- The configmap is mounted in this default directory: /mnt/

- Executor is currently unable to parse more than one secret.

- The secret is mounted in this default directory: /tmp/
4 changes: 1 addition & 3 deletions experiments/kafka/kafka-broker-pod-failure/chaosutil.j2
@@ -1,6 +1,4 @@
{% if c_lib is defined and c_lib == 'chaoskube' %}
c_util: /chaoslib/chaoskube/pod_failure_by_chaoskube.yml
{% elif c_lib is defined and c_lib == 'powerfulseal' %}
{% if c_lib is defined and c_lib == 'powerfulseal' %}
c_util: /chaoslib/powerfulseal/pod_failure_by_powerfulseal.yml
{% else %}
c_util: /chaoslib/litmus/pod_failure_by_litmus.yml
Expand Down
Expand Up @@ -8,6 +8,7 @@
c_interval: "{{ lookup('env','CHAOS_INTERVAL') }}"
c_force: "{{ lookup('env','FORCE') }}"
c_lib: "{{ lookup('env','LIB') }}"
c_svc_acc: "{{ lookup('env','CHAOS_SERVICE_ACCOUNT') }}"
kill_count: "{{ lookup('env','KILL_COUNT') }}"
kafka_instance: "{{ lookup('env','KAFKA_INSTANCE_NAME') }}"
kafka_ns: "{{ lookup('env','KAFKA_NAMESPACE') }}"
Expand Down Expand Up @@ -67,7 +68,6 @@
vars:
app_ns: "{{ kafka_ns }}"
app_label: "{{ kafka_label }}"

# derived from the 'kafka_broker_util' task
app_pod_name: "{{ kafka_broker }}"

Expand Down
4 changes: 4 additions & 0 deletions sonar-project.properties
Expand Up @@ -9,3 +9,7 @@ sonar.sources=.

# Encoding of the source code. Default is default system encoding
#sonar.sourceEncoding=UTF-8

# Exclude the ansible plugin/utils files from analysis
sonar.exclusions=build/utils/**/*,build/plugins/**/*
sonar.tests=contribute/developer_guide
32 changes: 16 additions & 16 deletions utils/apps/kafka/kafka_cluster_health.yml
Expand Up @@ -12,8 +12,8 @@
vars:
delay: 1
retries: 60
a_ns: "{{ zk_ns }}"
a_label: "{{ zk_label }}"
app_ns: "{{ zk_ns }}"
app_label: "{{ zk_label }}"

- name: Obtain pods name of any one of the zookeeper pods
shell: >
Expand Down Expand Up @@ -51,19 +51,19 @@

when: "kafka_instance is defined and kafka_instance != ''"

- block:
- name: Derive the available kafka brokers from zookeeper
shell: >
kubectl exec {{ zk_pod_name }} -n {{ zk_ns }} bash
-- zkCli.sh -server {{ zk_service }}:{{ zk_port }}
ls /brokers/ids | tail -n 1 | tr -d '[],' | tr ' ' '\n' | wc -l
args:
executable: /bin/bash
register: kafka_available_brokers
# - block:
# - name: Derive the available kafka brokers from zookeeper
# shell: >
# kubectl exec {{ zk_pod_name }} -n {{ zk_ns }} bash
# -- zkCli.sh -server {{ zk_service }}:{{ zk_port }}
# ls /brokers/ids | tail -n 1 | tr -d '[],' | tr ' ' '\n' | wc -l
# args:
# executable: /bin/bash
# register: kafka_available_brokers

- name: Check whether all kafka brokers are alive
debug:
msg: "All Kafka brokers are alive"
failed_when: "kafka_sts_replicas.stdout != kafka_available_brokers.stdout"
# - name: Check whether all kafka brokers are alive
# debug:
# msg: "All Kafka brokers are alive"
# failed_when: "kafka_sts_replicas.stdout != kafka_available_brokers.stdout"

when: "kafka_instance is not defined or kafka_instance == ''"
# when: "kafka_instance is not defined or kafka_instance == ''"
4 changes: 2 additions & 2 deletions utils/cloud/aws/aws_configure.yml
Expand Up @@ -10,5 +10,5 @@

- name: Copying aws credentials from cloud_config
copy:
src: /mnt/cloud_config.yml
dest: /root/.aws/credentials
src: /tmp/cloud_config.yml
dest: /root/.aws/credentials

0 comments on commit bf8104e

Please sign in to comment.