Skip to content
This repository was archived by the owner on Aug 7, 2025. It is now read-only.

Commit b6c7cf1

Browse files
Graham Whaleydklyle
authored andcommitted
metrics: make pods_per_gb valid JSON
Under some circumstances, the pod_per_gb value would come out as <0, and be generated without any leading 0's (such as `.14` rather than `0.14`). This is not valid JSON, and would break the report generation parsing in R. Use `printf` to force a leading 0 prefix onto the value. Signed-off-by: Graham Whaley <graham.whaley@intel.com>
1 parent f146c77 commit b6c7cf1

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

metrics/scaling/k8s_scale.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ EOF
169169
if [ $n_pods -eq 0 ]; then
170170
local pods_per_gb=0
171171
else
172-
local pods_per_gb=$(bc -l <<< "scale=2; ($total_mem_used/1024) / $n_pods")
172+
local pods_per_gb=$(printf "%0f" $(bc -l <<< "scale=2; ($total_mem_used/1024) / $n_pods"))
173173
fi
174174
local mem_json="$(cat << EOF
175175
"memory": {

metrics/scaling/k8s_scale_nc.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ EOF
195195
if [ $n_pods -eq 0 ]; then
196196
local pods_per_gb=0
197197
else
198-
local pods_per_gb=$(bc -l <<< "scale=2; ($total_mem_used/1024) / $n_pods")
198+
local pods_per_gb=$(printf "%0f" $(bc -l <<< "scale=2; ($total_mem_used/1024) / $n_pods"))
199199
fi
200200
local mem_json="$(cat << EOF
201201
"memory": {

0 commit comments

Comments
 (0)