From 9b0bcdbf0e39d9191eb8fbfefd7d1a2d937a44ab Mon Sep 17 00:00:00 2001 From: prubenda Date: Wed, 14 Jul 2021 14:50:37 -0400 Subject: [PATCH] Adding node memory hog scenario --- config/config.yaml | 10 +++++++--- kraken/litmus/common_litmus.py | 13 +++++++++---- scenarios/node_io_engine.yaml | 35 ++++++++++++++++++++++++++++++++++ scenarios/node_mem_engine.yaml | 28 +++++++++++++++++++++++++++ 4 files changed, 79 insertions(+), 7 deletions(-) create mode 100644 scenarios/node_io_engine.yaml create mode 100644 scenarios/node_mem_engine.yaml diff --git a/config/config.yaml b/config/config.yaml index 273f5c83..3d53b412 100644 --- a/config/config.yaml +++ b/config/config.yaml @@ -2,7 +2,7 @@ kraken: distribution: openshift # Distribution can be kubernetes or openshift kubeconfig_path: /root/.kube/config # Path to kubeconfig exit_on_failure: False # Exit when a post action scenario fails - litmus_version: v1.10.0 # Litmus version to install + litmus_version: v1.13.6 # Litmus version to install litmus_uninstall: False # If you want to uninstall litmus if failure chaos_scenarios: # List of policies/chaos scenarios to load - container_scenarios: # List of chaos pod scenarios to load @@ -19,8 +19,12 @@ kraken: - time_scenarios: # List of chaos time scenarios to load - scenarios/time_scenarios_example.yml - litmus_scenarios: # List of litmus scenarios to load - - - https://hub.litmuschaos.io/api/chaos/1.10.0?file=charts/generic/node-cpu-hog/rbac.yaml - - scenarios/node_cpu_hog_engine.yaml + - - https://hub.litmuschaos.io/api/chaos/1.13.6?file=charts/generic/node-cpu-hog/rbac.yaml + - scenarios/node_hog_engine.yaml + - - https://hub.litmuschaos.io/api/chaos/1.13.6?file=charts/generic/node-memory-hog/rbac.yaml + - scenarios/node_mem_engine.yaml + - - https://hub.litmuschaos.io/api/chaos/1.13.6?file=charts/generic/node-io-stress/rbac.yaml + - scenarios/node_io_engine.yaml - cluster_shut_down_scenarios: - - scenarios/cluster_shut_down_scenario.yml - scenarios/post_action_shut_down.py diff --git a/kraken/litmus/common_litmus.py b/kraken/litmus/common_litmus.py index fda58d04..9993bc77 100644 --- a/kraken/litmus/common_litmus.py +++ b/kraken/litmus/common_litmus.py @@ -56,7 +56,12 @@ def run(scenarios_list, config, litmus_namespaces, litmus_uninstall, wait_durati # Install litmus and wait until pod is running def install_litmus(version): - runcommand.invoke("kubectl apply -f " "https://litmuschaos.github.io/litmus/litmus-operator-%s.yaml" % version) + litmus_install = runcommand.invoke( + "kubectl apply -f " "https://litmuschaos.github.io/litmus/litmus-operator-%s.yaml" % version + ) + if "unable" in litmus_install: + logging.info("Unable to install litmus because " + str(litmus_install)) + sys.exit(1) runcommand.invoke( "oc patch -n litmus deployment.apps/chaos-operator-ce --type=json --patch ' " @@ -112,7 +117,7 @@ def check_experiment(engine_name, experiment_name, namespace): chaos_result = runcommand.invoke( "kubectl get chaosresult %s" "-%s -n %s -o " - "jsonpath='{.status.experimentstatus.verdict}'" % (engine_name, experiment_name, namespace) + "jsonpath='{.status.experimentStatus.verdict}'" % (engine_name, experiment_name, namespace) ) result_counter = 0 status = chaos_result.strip() @@ -122,7 +127,7 @@ def check_experiment(engine_name, experiment_name, namespace): chaos_result = runcommand.invoke( "kubectl get chaosresult %s" "-%s -n %s -o " - "jsonpath='{.status.experimentstatus.verdict}'" % (engine_name, experiment_name, namespace) + "jsonpath='{.status.experimentStatus.verdict}'" % (engine_name, experiment_name, namespace) ) status = chaos_result.strip() if result_counter >= max_tries: @@ -139,7 +144,7 @@ def check_experiment(engine_name, experiment_name, namespace): chaos_result = runcommand.invoke( "kubectl get chaosresult %s" "-%s -n %s -o jsonpath=" - "'{.status.experimentstatus.failStep}'" % (engine_name, experiment_name, namespace) + "'{.status.experimentStatus.failStep}'" % (engine_name, experiment_name, namespace) ) logging.info("Chaos result failed information: " + str(chaos_result)) return False diff --git a/scenarios/node_io_engine.yaml b/scenarios/node_io_engine.yaml new file mode 100644 index 00000000..29ebb9f2 --- /dev/null +++ b/scenarios/node_io_engine.yaml @@ -0,0 +1,35 @@ +apiVersion: litmuschaos.io/v1alpha1 +kind: ChaosEngine +metadata: + name: nginx-chaos + namespace: default +spec: + # It can be delete/retain + jobCleanUpPolicy: 'retain' + # It can be active/stop + engineState: 'active' + chaosServiceAccount: node-io-stress-sa + experiments: + - name: node-io-stress + spec: + components: + env: + # set chaos duration (in sec) as desired + - name: TOTAL_CHAOS_DURATION + value: '40' + + ## specify the size as percentage of free space on the file system + - name: FILESYSTEM_UTILIZATION_PERCENTAGE + value: '100' + + ## Number of core of CPU + - name: CPU + value: '1' + + ## Total number of workers default value is 4 + - name: NUMBER_OF_WORKERS + value: '3' + + ## enter the comma separated target nodes name + - name: TARGET_NODES + value: '' diff --git a/scenarios/node_mem_engine.yaml b/scenarios/node_mem_engine.yaml new file mode 100644 index 00000000..0c928d94 --- /dev/null +++ b/scenarios/node_mem_engine.yaml @@ -0,0 +1,28 @@ +apiVersion: litmuschaos.io/v1alpha1 +kind: ChaosEngine +metadata: + name: nginx-chaos + namespace: default +spec: + # It can be delete/retain + jobCleanUpPolicy: 'retain' + # It can be active/stop + engineState: 'active' + chaosServiceAccount: node-memory-hog-sa + experiments: + - name: node-memory-hog + spec: + components: + env: + # set chaos duration (in sec) as desired + - name: TOTAL_CHAOS_DURATION + value: '30' + + ## Specify the size as percent of total node capacity Ex: '30' + ## Note: For consuming memory in mebibytes change the variable to MEMORY_CONSUMPTION_MEBIBYTES + - name: MEMORY_CONSUMPTION_PERCENTAGE + value: '30' + + # ENTER THE COMMA SEPARATED TARGET NODES NAME + - name: TARGET_NODES + value: ''