From 0c25a43ae26707ea45293d806bdd8fc37ed5b52d Mon Sep 17 00:00:00 2001 From: Kevin Sandi Date: Thu, 17 Mar 2022 17:04:29 -0600 Subject: [PATCH] Feat: Append build result to cost file Change-Id: I0f08f364432d4f102655dfe80e98d5202a6b0349 Signed-off-by: Kevin Sandi --- job-cost/format-csv | 6 +++--- .../notes/append-job-status-to-costs-file-ca6935984177f089.yaml | 6 ++++++ shell/job-cost.sh | 4 ++-- 3 files changed, 11 insertions(+), 5 deletions(-) create mode 100644 releasenotes/notes/append-job-status-to-costs-file-ca6935984177f089.yaml diff --git a/job-cost/format-csv b/job-cost/format-csv index 4a6e1140..8c521f23 100755 --- a/job-cost/format-csv +++ b/job-cost/format-csv @@ -16,8 +16,8 @@ set -euf cost_file=$1 -while IFS="," read -r job_name build_number date resource uptime cost stack_cost; do +while IFS="," read -r job_name build_number date resource uptime cost stack_cost build_result; do [[ $resource == "0" ]] && resource='unknown' - printf "%s,%s,%s,%s,%d,%.2f,%.2f\n" "$job_name" "$build_number" "$date" \ - "$resource" "$uptime" "$cost" "$stack_cost" + printf "%s,%s,%s,%s,%d,%.2f,%.2f,%s\n" "$job_name" "$build_number" "$date" \ + "$resource" "$uptime" "$cost" "$stack_cost" "$build_result" done < "$cost_file" diff --git a/releasenotes/notes/append-job-status-to-costs-file-ca6935984177f089.yaml b/releasenotes/notes/append-job-status-to-costs-file-ca6935984177f089.yaml new file mode 100644 index 00000000..05aeade9 --- /dev/null +++ b/releasenotes/notes/append-job-status-to-costs-file-ca6935984177f089.yaml @@ -0,0 +1,6 @@ +--- +features: + - | + Append build result to cost.csv file. This would be useful to capture stats + for unattended jobs and potentially send out reports to PTL's on resource + usage stats. diff --git a/shell/job-cost.sh b/shell/job-cost.sh index b856f6a5..e5e18106 100644 --- a/shell/job-cost.sh +++ b/shell/job-cost.sh @@ -85,5 +85,5 @@ echo "INFO: Archiving Costs" date=$(TZ=GMT date +'%Y-%m-%d %H:%M:%S') # Format the uptime, cost & stack_cost fields -printf "%s,%s,%s,%s,%d,%.2f,%.2f\n" "$JOB_NAME" "$BUILD_NUMBER" "$date" \ - "$resource" "$uptime" "$cost" "$stack_cost" > "$WORKSPACE/archives/cost.csv" +printf "%s,%s,%s,%s,%d,%.2f,%.2f,%s\n" "$JOB_NAME" "$BUILD_NUMBER" "$date" \ + "$resource" "$uptime" "$cost" "$stack_cost" "$BUILD_RESULT" > "$WORKSPACE/archives/cost.csv" -- 2.16.6