Skip to content

Commit b6e9bf4

Browse files
committed
Fix the case of no compute nodes and fix the case when CE and Queue have different name.
1 parent e68f6ce commit b6e9bf4

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

custom-metrics/1m-cost-metrics.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ compute_nodes_total_cost=0
2121

2222
for queue in $queues; do
2323

24-
instance_type=$(cat "${cluster_config_file}" \
25-
| jq -r --arg queue $queue '.cluster.queue_settings | to_entries[].value.compute_resource_settings | to_entries[] | select(.key==$queue).value.instance_type')
24+
instance_type=$(cat "${cluster_config_file}" | jq -r --arg queue $queue '.cluster.queue_settings | to_entries[] | select(.key==$queue).value.compute_resource_settings | to_entries[]| .value.instance_type')
2625

2726
compute_node_h_price=$(aws pricing get-products \
2827
--region us-east-1 \
@@ -46,7 +45,7 @@ for queue in $queues; do
4645
'Type=TERM_MATCH,Field=volumeApiName,Value=gp2' \
4746
| jq -r '.terms.OnDemand | to_entries[] | .value.priceDimensions | to_entries[] | .value.pricePerUnit.USD')
4847

49-
total_num_compute_nodes=$(/opt/slurm/bin/sinfo --noheader --partition=$queue | egrep -v "idle~" | awk '{sum += $4} END {print sum}')
48+
total_num_compute_nodes=$(/opt/slurm/bin/sinfo --noheader --partition=$queue | egrep -v "idle~" | awk '{sum += $4} END {if (sum) print sum; else print 0; }')
5049

5150
ebs_volume_size=$(aws cloudformation describe-stacks --stack-name $stack_name --region $cfn_region | jq -r '.Stacks[0].Parameters | map(select(.ParameterKey == "ComputeRootVolumeSize"))[0].ParameterValue')
5251
compute_ebs_volume_cost=$(echo "scale=2; $ebs_cost_gb_month * $total_num_compute_nodes * $ebs_volume_size / 720" | bc)

0 commit comments

Comments
 (0)