From c1aef504a85891853521b00d4eef09ef5270293f Mon Sep 17 00:00:00 2001 From: Tullio Sebastiani Date: Tue, 26 Nov 2024 16:39:46 +0100 Subject: [PATCH] Added $DEBUG variable and disabled all the debug and cat commands (#230) * added $DEBUG variable and disabled all the debug and cat commands by default Signed-off-by: Tullio Sebastiani * added DEBUG variable to documentation Signed-off-by: Tullio Sebastiani --------- Signed-off-by: Tullio Sebastiani --- application-outages/run.sh | 12 +++++++++--- container-scenarios/run.sh | 15 ++++++++++----- docs/all_scenarios_env.md | 1 + env.sh | 1 + network-chaos/run.sh | 11 ++++++----- node-cpu-hog/run.sh | 14 ++++++++------ node-io-hog/run.sh | 14 ++++++++------ node-memory-hog/run.sh | 13 ++++++++----- node-scenarios/run.sh | 15 +++++++++------ pod-network-chaos/run.sh | 18 ++++++++++-------- pod-scenarios/run.sh | 18 +++++++++++------- power-outages/run.sh | 16 +++++++++------- pvc-scenario/run.sh | 10 +++++----- service-disruption-scenarios/run.sh | 16 ++++++++++------ service-hijacking/run.sh | 15 +++++++++------ syn-flood/run.sh | 8 ++++---- time-scenarios/run.sh | 9 +++++---- zone-outages/run.sh | 9 +++++---- 18 files changed, 128 insertions(+), 87 deletions(-) diff --git a/application-outages/run.sh b/application-outages/run.sh index b92462e..c627af1 100755 --- a/application-outages/run.sh +++ b/application-outages/run.sh @@ -1,14 +1,20 @@ #!/bin/bash -set -ex # Source env.sh to read all the vars source /home/krkn/main_env.sh source /home/krkn/env.sh +source /home/krkn/common_run.sh + + +if [[ $DEBUG == "True" ]];then + set -ex + ls -la /home/krkn/.kube +fi + + -ls -la /home/krkn/.kube -source /home/krkn/common_run.sh checks config_setup diff --git a/container-scenarios/run.sh b/container-scenarios/run.sh index 713420f..af7cd2a 100755 --- a/container-scenarios/run.sh +++ b/container-scenarios/run.sh @@ -1,12 +1,15 @@ #!/bin/bash -set -ex - # Source env.sh to read all the vars source /home/krkn/main_env.sh source /home/krkn/env.sh - source /home/krkn/common_run.sh + +if [[ $DEBUG == "True" ]];then + set -ex +fi + + checks config_setup @@ -17,9 +20,11 @@ envsubst < /home/krkn/kraken/config/config.yaml.template > /home/krkn/kraken/con # Run Kraken cd /home/krkn/kraken -cat config/container_scenario_config.yaml +if [[ $DEBUG == "True" ]];then + cat config/container_scenario_config.yaml + cat scenarios/container_scenario.yaml +fi -cat scenarios/container_scenario.yaml python3.9 run_kraken.py --config=config/container_scenario_config.yaml diff --git a/docs/all_scenarios_env.md b/docs/all_scenarios_env.md index 9af0a7d..b323dc4 100644 --- a/docs/all_scenarios_env.md +++ b/docs/all_scenarios_env.md @@ -43,5 +43,6 @@ TELEMETRY_FILTER_PATTER | Filter logs based on certain time stamp patterns |["(\ TELEMETRY_CLI_PATH | OC Cli path, if not specified will be search in $PATH | _blank_ | ELASTIC_SERVER | Be able to track telemtry data in elasticsearch, this is the url of the elasticsearch data storage | _blank_ | ELASTIC_INDEX | Elastic search index pattern to post results to | _blank_ | +DEBUG| If set to "True" enables krkn Verbose output | "False" | **NOTE**: For setting the TELEMETRY_ARCHIVE_SIZE,the higher the number of archive files will be produced and uploaded (and processed by backup_thread simultaneously).For unstable/slow connection is better to keep this value low increasing the number of backup_threads, in this way, on upload failure, the retry will happen only on the failed chunk without affecting the whole upload. diff --git a/env.sh b/env.sh index 6cb86ce..50b20fa 100755 --- a/env.sh +++ b/env.sh @@ -54,3 +54,4 @@ export TELEMETRY_EVENTS_BACKUP=${TELEMETRY_EVENTS_BACKUP:=True} # Set KUBECONFIG to mounted kubeconfig export KUBECONFIG=${KRKN_KUBE_CONFIG} +export DEBUG=${DEBUG:="False"} diff --git a/network-chaos/run.sh b/network-chaos/run.sh index 58ed7f7..c0eed5d 100755 --- a/network-chaos/run.sh +++ b/network-chaos/run.sh @@ -1,14 +1,15 @@ #!/bin/bash - -set -ex - # Source env.sh to read all the vars source /home/krkn/main_env.sh source /home/krkn/env.sh +source /home/krkn/common_run.sh + +if [[ $DEBUG == "True" ]];then + set -ex + ls -la /home/krkn/.kube +fi -ls -la /home/krkn/.kube -source /home/krkn/common_run.sh checks config_setup diff --git a/node-cpu-hog/run.sh b/node-cpu-hog/run.sh index 0c83696..52aae47 100755 --- a/node-cpu-hog/run.sh +++ b/node-cpu-hog/run.sh @@ -1,7 +1,5 @@ #!/bin/bash -set -ex - ROOT_FOLDER="/home/krkn" KRAKEN_FOLDER="$ROOT_FOLDER/kraken" SCENARIO_FOLDER="$KRAKEN_FOLDER/scenarios/kube/cpu-hog" @@ -9,9 +7,12 @@ SCENARIO_FOLDER="$KRAKEN_FOLDER/scenarios/kube/cpu-hog" # Source env.sh to read all the vars source $ROOT_FOLDER/main_env.sh source $ROOT_FOLDER/env.sh - source $ROOT_FOLDER/common_run.sh +if [[ $DEBUG == "True" ]];then + set -ex +fi + setup_arcaflow_env "$SCENARIO_FOLDER" # Substitute config with environment vars defined envsubst < $KRAKEN_FOLDER/config/config.yaml.template > $KRAKEN_FOLDER/config/cpu_config.yaml @@ -21,9 +22,10 @@ config_setup # Run Kraken cd $KRAKEN_FOLDER -cat config/cpu_config.yaml - -cat scenarios/kube/cpu-hog/input.yaml +if [[ $DEBUG == "True" ]];then + cat scenarios/kube/cpu-hog/input.yaml + cat config/cpu_config.yaml +fi python3.9 run_kraken.py --config=config/cpu_config.yaml diff --git a/node-io-hog/run.sh b/node-io-hog/run.sh index 7b20c69..5dc57ff 100755 --- a/node-io-hog/run.sh +++ b/node-io-hog/run.sh @@ -1,7 +1,5 @@ #!/bin/bash -set -ex - ROOT_FOLDER="/home/krkn" KRAKEN_FOLDER="$ROOT_FOLDER/kraken" SCENARIO_FOLDER="$KRAKEN_FOLDER/scenarios/kube/io-hog" @@ -9,9 +7,12 @@ SCENARIO_FOLDER="$KRAKEN_FOLDER/scenarios/kube/io-hog" # Source env.sh to read all the vars source $ROOT_FOLDER/main_env.sh source $ROOT_FOLDER/env.sh - source $ROOT_FOLDER/common_run.sh +if [[ $DEBUG == "True" ]];then + set -ex +fi + setup_arcaflow_env "$SCENARIO_FOLDER" # Substitute config with environment vars defined envsubst < $KRAKEN_FOLDER/config/config.yaml.template > $KRAKEN_FOLDER/config/io_config.yaml @@ -21,9 +22,10 @@ config_setup # Run Kraken cd $KRAKEN_FOLDER -cat config/io_config.yaml - -cat scenarios/kube/io-hog/input.yaml +if [[ $DEBUG == "True" ]];then + cat config/io_config.yaml + cat scenarios/kube/io-hog/input.yaml +fi python3.9 run_kraken.py --config=config/io_config.yaml diff --git a/node-memory-hog/run.sh b/node-memory-hog/run.sh index 0274024..ea0e323 100755 --- a/node-memory-hog/run.sh +++ b/node-memory-hog/run.sh @@ -1,7 +1,5 @@ #!/bin/bash -set -ex - ROOT_FOLDER="/home/krkn" KRAKEN_FOLDER="$ROOT_FOLDER/kraken" SCENARIO_FOLDER="$KRAKEN_FOLDER/scenarios/kube/memory-hog" @@ -9,9 +7,12 @@ SCENARIO_FOLDER="$KRAKEN_FOLDER/scenarios/kube/memory-hog" # Source env.sh to read all the vars source $ROOT_FOLDER/main_env.sh source $ROOT_FOLDER/env.sh - source $ROOT_FOLDER/common_run.sh +if [[ $DEBUG == "True" ]];then + set -ex +fi + setup_arcaflow_env "$SCENARIO_FOLDER" # Substitute config with environment vars defined envsubst < $KRAKEN_FOLDER/config/config.yaml.template > $KRAKEN_FOLDER/config/mem_config.yaml @@ -23,8 +24,10 @@ config_setup # Run Kraken cd $KRAKEN_FOLDER -cat config/mem_config.yaml +if [[ $DEBUG == "True" ]];then + cat config/mem_config.yaml + cat scenarios/kube/memory-hog/input.yaml +fi -cat scenarios/kube/memory-hog/input.yaml python3.9 run_kraken.py --config=config/mem_config.yaml diff --git a/node-scenarios/run.sh b/node-scenarios/run.sh index e4faaeb..b0a6d01 100755 --- a/node-scenarios/run.sh +++ b/node-scenarios/run.sh @@ -1,12 +1,13 @@ #!/bin/bash - -set -ex - # Source env.sh to read all the vars source /home/krkn/main_env.sh source /home/krkn/env.sh - source /home/krkn/common_run.sh + +if [[ $DEBUG == "True" ]];then + set -ex +fi + checks # Substitute config with environment vars defined @@ -43,8 +44,10 @@ envsubst < /home/krkn/kraken/config/config.yaml.template > /home/krkn/kraken/con # Run Kraken cd /home/krkn/kraken -cat config/node_scenario_config.yaml -cat scenarios/node_scenario.yaml +if [[ $DEBUG == "True" ]];then + cat config/node_scenario_config.yaml + cat scenarios/node_scenario.yaml +fi python3.9 run_kraken.py --config=config/node_scenario_config.yaml diff --git a/pod-network-chaos/run.sh b/pod-network-chaos/run.sh index c7e3c1c..77be6e8 100755 --- a/pod-network-chaos/run.sh +++ b/pod-network-chaos/run.sh @@ -1,14 +1,14 @@ #!/bin/bash - -set -ex - # Source env.sh to read all the vars source /home/krkn/main_env.sh source /home/krkn/env.sh +source /home/krkn/common_run.sh -ls -la /home/krkn/.kube +if [[ $DEBUG == "True" ]];then + set -ex + ls -la /home/krkn/.kube +fi -source /home/krkn/common_run.sh checks config_setup @@ -18,14 +18,16 @@ envsubst < /home/krkn/kraken/config/config.yaml.template > /home/krkn/kraken/con # Validate if namespace parameter is set if [[ -z $NAMESPACE ]]; then - echo "Requires NAMASPACE parameter to be set, please check" + echo "Requires NAMESPACE parameter to be set, please check" exit 1 fi # Run Kraken cd /home/krkn/kraken -cat /home/krkn/kraken/config/pod_network_scenario_config.yaml -cat /home/krkn/kraken/scenarios/pod_network_scenario.yaml +if [[ $DEBUG == "True" ]];then + cat /home/krkn/kraken/config/pod_network_scenario_config.yaml + cat /home/krkn/kraken/scenarios/pod_network_scenario.yaml +fi python3.9 run_kraken.py --config=/home/krkn/kraken/config/pod_network_scenario_config.yaml diff --git a/pod-scenarios/run.sh b/pod-scenarios/run.sh index 47858c2..7f285b1 100755 --- a/pod-scenarios/run.sh +++ b/pod-scenarios/run.sh @@ -1,14 +1,14 @@ #!/bin/bash - -set -ex - # Source env.sh to read all the vars source /home/krkn/main_env.sh source /home/krkn/env.sh +source /home/krkn/common_run.sh -ls -la /home/krkn/.kube +if [[ $DEBUG == "True" ]];then + set -ex + ls -la /home/krkn/.kube +fi -source /home/krkn/common_run.sh checks config_setup @@ -23,7 +23,11 @@ envsubst < /home/krkn/kraken/config/config.yaml.template > /home/krkn/kraken/con # Run Kraken cd /home/krkn/kraken -cat /home/krkn/kraken/config/pod_scenario_config.yaml -cat /home/krkn/kraken/scenarios/pod_scenario.yaml + +if [[ $DEBUG == "True" ]];then + cat /home/krkn/kraken/config/pod_scenario_config.yaml + cat /home/krkn/kraken/scenarios/pod_scenario.yaml +fi + python3.9 run_kraken.py --config=/home/krkn/kraken/config/pod_scenario_config.yaml diff --git a/power-outages/run.sh b/power-outages/run.sh index c8f3ec8..a066a12 100755 --- a/power-outages/run.sh +++ b/power-outages/run.sh @@ -1,12 +1,13 @@ #!/bin/bash - -set -ex - # Source env.sh to read all the vars source /home/krkn/main_env.sh source /home/krkn/env.sh - source /home/krkn/common_run.sh + +if [[ $DEBUG == "True" ]];then + set -ex +fi + config_setup checks @@ -17,8 +18,9 @@ envsubst < /home/krkn/kraken/config/config.yaml.template > /home/krkn/kraken/con # Run Kraken cd /home/krkn/kraken -cat config/shut_down_config.yaml - -cat scenarios/cluster_shut_down_scenario.yml +if [[ $DEBUG == "True" ]];then + cat config/shut_down_config.yaml + cat scenarios/cluster_shut_down_scenario.yml +fi python3.9 run_kraken.py --config=config/shut_down_config.yaml diff --git a/pvc-scenario/run.sh b/pvc-scenario/run.sh index e4222a9..a677200 100755 --- a/pvc-scenario/run.sh +++ b/pvc-scenario/run.sh @@ -1,14 +1,14 @@ #!/bin/bash - -set -ex - # Source env.sh to read all the vars source /home/krkn/main_env.sh source /home/krkn/env.sh +source /home/krkn/common_run.sh -ls -la /home/krkn/.kube +if [[ $DEBUG == "True" ]];then + set -ex + ls -la /home/krkn/.kube +fi -source /home/krkn/common_run.sh checks config_setup diff --git a/service-disruption-scenarios/run.sh b/service-disruption-scenarios/run.sh index f2b9384..e3b68f7 100755 --- a/service-disruption-scenarios/run.sh +++ b/service-disruption-scenarios/run.sh @@ -1,12 +1,13 @@ #!/bin/bash - -set -ex - # Source env.sh to read all the vars source /home/krkn/main_env.sh source /home/krkn/env.sh - source /home/krkn/common_run.sh + +if [[ $DEBUG == "True" ]];then + set -ex +fi + checks config_setup @@ -17,7 +18,10 @@ envsubst < /home/krkn/kraken/config/config.yaml.template > /home/krkn/kraken/con # Run Kraken cd /home/krkn/kraken -cat scenarios/namespace_scenario.yaml -cat config/namespace_config.yaml +if [[ $DEBUG == "True" ]];then + cat scenarios/namespace_scenario.yaml + cat config/namespace_config.yaml +fi + python3.9 run_kraken.py --config=config/namespace_config.yaml diff --git a/service-hijacking/run.sh b/service-hijacking/run.sh index af3e5b2..5cec0d8 100755 --- a/service-hijacking/run.sh +++ b/service-hijacking/run.sh @@ -1,12 +1,13 @@ #!/bin/bash - -set -ex - # Source env.sh to read all the vars source /home/krkn/main_env.sh source /home/krkn/env.sh - source /home/krkn/common_run.sh + +if [[ $DEBUG == "True" ]];then + set -ex +fi + checks # check if SCENARIO_BASE64 is set @@ -35,7 +36,9 @@ envsubst < /home/krkn/kraken/config/config.yaml.template > /home/krkn/kraken/con # Run Kraken cd /home/krkn/kraken -cat scenarios/service_hijacking.yaml -cat config/service_hijacking_config.yaml +if [[ $DEBUG == "True" ]];then + cat scenarios/service_hijacking.yaml + cat config/service_hijacking_config.yaml +fi python3.9 run_kraken.py --config=config/service_hijacking_config.yaml diff --git a/syn-flood/run.sh b/syn-flood/run.sh index 274f86f..7cc9586 100755 --- a/syn-flood/run.sh +++ b/syn-flood/run.sh @@ -1,7 +1,4 @@ #!/bin/bash - -set -ex - ROOT_FOLDER="/home/krkn" KRAKEN_FOLDER="$ROOT_FOLDER/kraken" SCENARIO_FOLDER="$KRAKEN_FOLDER/scenarios/syn-flood" @@ -9,9 +6,12 @@ SCENARIO_FOLDER="$KRAKEN_FOLDER/scenarios/syn-flood" # Source env.sh to read all the vars source $ROOT_FOLDER/main_env.sh source $ROOT_FOLDER/env.sh - source $ROOT_FOLDER/common_run.sh +if [[ $DEBUG == "True" ]];then + set -ex +fi + # Substitute config with environment vars defined envsubst < $KRAKEN_FOLDER/scenarios/syn-flood.yaml.template > $KRAKEN_FOLDER/scenarios/syn-flood.yaml envsubst < $KRAKEN_FOLDER/config/config.yaml.template > $KRAKEN_FOLDER/config/syn_flood_config.yaml diff --git a/time-scenarios/run.sh b/time-scenarios/run.sh index d336003..dddc536 100755 --- a/time-scenarios/run.sh +++ b/time-scenarios/run.sh @@ -1,12 +1,13 @@ #!/bin/bash - -set -ex - # Source env.sh to read all the vars source /home/krkn/main_env.sh source /home/krkn/env.sh - source /home/krkn/common_run.sh + +if [[ $DEBUG == "True" ]];then + set -ex +fi + checks config_setup diff --git a/zone-outages/run.sh b/zone-outages/run.sh index 5da46a1..c5346f4 100755 --- a/zone-outages/run.sh +++ b/zone-outages/run.sh @@ -1,12 +1,13 @@ #!/bin/bash - -set -ex - # Source env.sh to read all the vars source /home/krkn/main_env.sh source /home/krkn/env.sh - source /home/krkn/common_run.sh + +if [[ $DEBUG == "True" ]];then + set -ex +fi + checks config_setup