From 9510b068e0ddf59c9c3a45cfd77031814f4d2fdb Mon Sep 17 00:00:00 2001 From: Graham Whaley Date: Wed, 13 Nov 2019 14:10:43 +0000 Subject: [PATCH] metrics: cpu-load: save cpu-load config in JSON If the cpu-load function is enabled, save its config settings into the JSON results file. This required a little bit of re-sequencing of the json library calls, to ensure we did the init of the JSON early enough, but not more than once. Signed-off-by: Graham Whaley --- metrics/lib/common.bash | 8 +++++--- metrics/lib/cpu-load.bash | 14 ++++++++++++++ metrics/scaling/k8s_parallel.sh | 4 ---- metrics/scaling/k8s_scale.sh | 4 ---- metrics/scaling/k8s_scale_nc.sh | 4 ---- 5 files changed, 19 insertions(+), 15 deletions(-) diff --git a/metrics/lib/common.bash b/metrics/lib/common.bash index 2bb8193..dd76d98 100755 --- a/metrics/lib/common.bash +++ b/metrics/lib/common.bash @@ -89,12 +89,14 @@ framework_init() { init_stats $wait_time fi - # Initialise the cpu load generators - cpu_load_init - # And now we can set up our results storage then... metrics_json_init "k8s" save_config + + # Initialise the cpu load generators now - after json init, as they may + # produce some json results (config) data. + cpu_load_init + } framework_shutdown() { diff --git a/metrics/lib/cpu-load.bash b/metrics/lib/cpu-load.bash index c503b7d..77c3d28 100644 --- a/metrics/lib/cpu-load.bash +++ b/metrics/lib/cpu-load.bash @@ -71,6 +71,20 @@ cpu_per_node_init() { info "Sleeping ${cpu_load_post_deploy_sleep}s for cpu-load to settle" sleep ${cpu_load_post_deploy_sleep} fi + + # And store off our config into the JSON results + metrics_json_start_array + local json="$(cat << EOF + { + "LOAD_NODES_NCPU": "${SMF_CPU_LOAD_NODES_NCPU}", + "LOAD_NODES_PERCENT": "${SMF_CPU_LOAD_NODES_PERCENT}", + "LOAD_NODES_LIMIT": "${SMF_CPU_LOAD_NODES_LIMIT}", + "LOAD_NODES_REQUEST": "${SMF_CPU_LOAD_NODES_REQUEST}" + } +EOF +)" + metrics_json_add_array_element "$json" + metrics_json_end_array "cpu-load" } cpu_load_init() { diff --git a/metrics/scaling/k8s_parallel.sh b/metrics/scaling/k8s_parallel.sh index f67c006..e1c2646 100755 --- a/metrics/scaling/k8s_parallel.sh +++ b/metrics/scaling/k8s_parallel.sh @@ -130,10 +130,6 @@ init() { # Ensure we pre-cache the container image etc. warmup - - # And now we can set up our results storage then... - metrics_json_init "k8s" - save_config } save_config(){ diff --git a/metrics/scaling/k8s_scale.sh b/metrics/scaling/k8s_scale.sh index e0ef1a7..6d7066d 100755 --- a/metrics/scaling/k8s_scale.sh +++ b/metrics/scaling/k8s_scale.sh @@ -218,10 +218,6 @@ init() { # FIXME - we should probably 'warm up' the cluster with the container image(s) we will # use for testing, otherwise the download time will likely be included in the first pod # boot time. - - # And now we can set up our results storage then... - metrics_json_init "k8s" - save_config } save_config(){ diff --git a/metrics/scaling/k8s_scale_nc.sh b/metrics/scaling/k8s_scale_nc.sh index 2423de5..b92964d 100755 --- a/metrics/scaling/k8s_scale_nc.sh +++ b/metrics/scaling/k8s_scale_nc.sh @@ -244,10 +244,6 @@ init() { # FIXME - we should probably 'warm up' the cluster with the container image(s) we will # use for testing, otherwise the download time will likely be included in the first pod # boot time. - - # And now we can set up our results storage then... - metrics_json_init "k8s" - save_config } save_config(){