From 914aef6bf819be52c455d2e9c064a8d54425318f Mon Sep 17 00:00:00 2001 From: Tim Wright Date: Thu, 14 Nov 2024 23:40:21 +1300 Subject: [PATCH] try not to fail if performance data file is not set (#5262) --- .../cloud-init/artifacts/cse_benchmark_functions.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/parts/linux/cloud-init/artifacts/cse_benchmark_functions.sh b/parts/linux/cloud-init/artifacts/cse_benchmark_functions.sh index c06cfc66dae..9464298af9b 100644 --- a/parts/linux/cloud-init/artifacts/cse_benchmark_functions.sh +++ b/parts/linux/cloud-init/artifacts/cse_benchmark_functions.sh @@ -44,8 +44,12 @@ capture_benchmark() { process_benchmarks() { set +x - if [ ! -f ${PERFORMANCE_DATA_FILE} ]; then - echo '{}' > ${PERFORMANCE_DATA_FILE} + if [ -z "${PERFORMANCE_DATA_FILE}" ] ; then + return + fi + + if [ ! -f "${PERFORMANCE_DATA_FILE}" ]; then + echo '{}' > "${PERFORMANCE_DATA_FILE}" fi check_array_size benchmarks || { echo "Benchmarks array is empty"; return; } @@ -60,6 +64,6 @@ process_benchmarks() { '$script_object | .[$script_name] += $section_object') done - jq ". += $script_object" ${PERFORMANCE_DATA_FILE} > temp-perf-file.json && mv temp-perf-file.json ${PERFORMANCE_DATA_FILE} - chmod 755 ${PERFORMANCE_DATA_FILE} + jq ". += $script_object" "${PERFORMANCE_DATA_FILE}" > temp-perf-file.json && mv temp-perf-file.json "${PERFORMANCE_DATA_FILE}" + chmod 755 "${PERFORMANCE_DATA_FILE}" } \ No newline at end of file