From 80c61b1eee7b733fb0127bd49a0ff76ea62e7d12 Mon Sep 17 00:00:00 2001 From: Shubham Chaudhary Date: Wed, 13 May 2020 22:39:36 +0530 Subject: [PATCH] [Cherry-pick for RC2] (#1506) * update(pod-delete): Adding type casting in pod-delete experiment (#1503) Signed-off-by: shubhamchaudhary * feat(disk-fill): Adding Dynamic Variable for Container Path (#1502) * (feat) Adding Dynamic Variable for Container Path Signed-off-by: Rahul M Chheda * Adding appropriate comments Signed-off-by: Rahul M Chheda * feat(image): Using a comman image for stress-ng commands (#1462) Signed-off-by: Udit Gaurav Co-authored-by: Rahul M Chheda <53308066+rahulchheda@users.noreply.github.com> Co-authored-by: UDIT GAURAV <35391335+uditgaurav@users.noreply.github.com> --- chaoslib/litmus/disk_fill/disk_fill_pod.j2 | 2 +- chaoslib/litmus/node_cpu_hog/node-cpu-hog-pod.j2 | 1 - chaoslib/litmus/pod_delete/kill_random_pod.yml | 4 ++-- experiments/generic/disk_fill/disk_fill_ansible_logic.yml | 1 + experiments/generic/disk_fill/disk_fill_k8s_job.yml | 5 +++++ experiments/generic/node_cpu_hog/node_cpu_hog_k8s_job.yml | 2 +- .../generic/node_memory_hog/node_memory_hog_k8s_job.yml | 2 +- 7 files changed, 11 insertions(+), 6 deletions(-) diff --git a/chaoslib/litmus/disk_fill/disk_fill_pod.j2 b/chaoslib/litmus/disk_fill/disk_fill_pod.j2 index 9c64e8e63d6..eb3c2f77d15 100644 --- a/chaoslib/litmus/disk_fill/disk_fill_pod.j2 +++ b/chaoslib/litmus/disk_fill/disk_fill_pod.j2 @@ -27,4 +27,4 @@ spec: volumes: - name: udev hostPath: - path: /var/lib/docker/containers \ No newline at end of file + path: {{ container_path }} \ No newline at end of file diff --git a/chaoslib/litmus/node_cpu_hog/node-cpu-hog-pod.j2 b/chaoslib/litmus/node_cpu_hog/node-cpu-hog-pod.j2 index e7fe63e516b..53e648515da 100644 --- a/chaoslib/litmus/node_cpu_hog/node-cpu-hog-pod.j2 +++ b/chaoslib/litmus/node_cpu_hog/node-cpu-hog-pod.j2 @@ -15,5 +15,4 @@ spec: - image: {{ cpu_stress_image }} imagePullPolicy: Always name: node-cpu-hog - command: ["stress"] args: ["--cpu", "{{ cpu_limit }}", "--timeout", "{{ c_duration }}"] diff --git a/chaoslib/litmus/pod_delete/kill_random_pod.yml b/chaoslib/litmus/pod_delete/kill_random_pod.yml index 6c4e3c727ee..d0b87e30fac 100644 --- a/chaoslib/litmus/pod_delete/kill_random_pod.yml +++ b/chaoslib/litmus/pod_delete/kill_random_pod.yml @@ -107,13 +107,13 @@ retries: 90 when: "type is defined and type != ''" - when: "chaosDiffTimeStamp is not defined or (chaosDiffTimeStamp is defined and chaosDiffTimeStamp < c_duration)" + when: "chaosDiffTimeStamp is not defined or (chaosDiffTimeStamp is defined and chaosDiffTimeStamp|int < c_duration|int)" # chaos_status tracking the status of chaos, If it is active means chaos is in progress # If it is terminate means chaos is ended. - name: "[Mark]: Setting chaos_status to terminate" set_fact: chaos_status: "terminate" - when: "chaosDiffTimeStamp is defined and chaosDiffTimeStamp >= c_duration" + when: "chaosDiffTimeStamp is defined and chaosDiffTimeStamp|int >= c_duration|int" when: "chaos_status is not defined or (chaos_status is defined and chaos_status == 'active')" diff --git a/experiments/generic/disk_fill/disk_fill_ansible_logic.yml b/experiments/generic/disk_fill/disk_fill_ansible_logic.yml index 542564f9ab7..d8480e32e8e 100644 --- a/experiments/generic/disk_fill/disk_fill_ansible_logic.yml +++ b/experiments/generic/disk_fill/disk_fill_ansible_logic.yml @@ -17,6 +17,7 @@ chaos_pod_name: "{{ lookup('env','POD_NAME') }}" c_ns: "{{ lookup('env','CHAOS_NAMESPACE') }}" c_lib: "{{ lookup('env','LIB') }}" + container_path: "{{ lookup('env','CONTAINER_PATH') }}" tasks: - block: diff --git a/experiments/generic/disk_fill/disk_fill_k8s_job.yml b/experiments/generic/disk_fill/disk_fill_k8s_job.yml index 00971f73b30..41e0fe48baa 100644 --- a/experiments/generic/disk_fill/disk_fill_k8s_job.yml +++ b/experiments/generic/disk_fill/disk_fill_k8s_job.yml @@ -52,5 +52,10 @@ spec: - name: CHAOS_NAMESPACE value: '' + # provide the container runtime path + # default set to docker + - name: CONTAINER_PATH + value: '/var/lib/docker/containers' + command: ["/bin/bash"] args: ["-c", "ansible-playbook ./experiments/generic/disk_fill/disk_fill_ansible_logic.yml -i /etc/ansible/hosts -vv; exit 0"] \ No newline at end of file diff --git a/experiments/generic/node_cpu_hog/node_cpu_hog_k8s_job.yml b/experiments/generic/node_cpu_hog/node_cpu_hog_k8s_job.yml index 9267bbd709d..bbb5aa12521 100644 --- a/experiments/generic/node_cpu_hog/node_cpu_hog_k8s_job.yml +++ b/experiments/generic/node_cpu_hog/node_cpu_hog_k8s_job.yml @@ -44,7 +44,7 @@ spec: # provide lib image - name: LIB_IMAGE - value: 'litmuschaos/cpu:latest' + value: 'litmuschaos/stress-ng:latest' ## PERIOD TO WAIT BEFORE INJECTION OF CHAOS IN SEC - name: RAMP_TIME diff --git a/experiments/generic/node_memory_hog/node_memory_hog_k8s_job.yml b/experiments/generic/node_memory_hog/node_memory_hog_k8s_job.yml index 04d159267d8..d3e9fc8222a 100644 --- a/experiments/generic/node_memory_hog/node_memory_hog_k8s_job.yml +++ b/experiments/generic/node_memory_hog/node_memory_hog_k8s_job.yml @@ -44,7 +44,7 @@ spec: # provide lib image - name: LIB_IMAGE - value: 'alexeiled/stress-ng:latest' + value: 'litmuschaos/stress-ng:latest' ## PERIOD TO WAIT BEFORE AND AFTER INJECTION OF CHAOS IN SEC - name: RAMP_TIME