Skip to content

Commit

Permalink
metrics: make pods_per_gb valid JSON
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
Graham Whaley authored and dklyle committed Nov 21, 2019
1 parent f146c77 commit b6c7cf1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion metrics/scaling/k8s_scale.sh
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ EOF
if [ $n_pods -eq 0 ]; then
local pods_per_gb=0
else
local pods_per_gb=$(bc -l <<< "scale=2; ($total_mem_used/1024) / $n_pods")
local pods_per_gb=$(printf "%0f" $(bc -l <<< "scale=2; ($total_mem_used/1024) / $n_pods"))
fi
local mem_json="$(cat << EOF
"memory": {
Expand Down
2 changes: 1 addition & 1 deletion metrics/scaling/k8s_scale_nc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ EOF
if [ $n_pods -eq 0 ]; then
local pods_per_gb=0
else
local pods_per_gb=$(bc -l <<< "scale=2; ($total_mem_used/1024) / $n_pods")
local pods_per_gb=$(printf "%0f" $(bc -l <<< "scale=2; ($total_mem_used/1024) / $n_pods"))
fi
local mem_json="$(cat << EOF
"memory": {
Expand Down

0 comments on commit b6c7cf1

Please sign in to comment.