@@ -16,10 +16,40 @@ status_checks() {
1616 expected_count=$1
1717
1818 output=$( ceph nvme-gw show $POOL $GROUP )
19- nvme_show=$( echo $output | grep -o ' "AVAILABLE"' | wc -l)
20- if [ " $nvme_show " -ne " $expected_count " ]; then
21- return 1
19+ # nvme_show=$(echo $output | grep -o '"AVAILABLE"' | wc -l)
20+ # if [ "$nvme_show" -ne "$expected_count" ]; then
21+ # return 1
22+ # fi
23+ total_ns=$( echo $output | jq ' .["num-namespaces"]' )
24+ total_gws=$( echo $output | jq ' .["num gws"]' )
25+ expected_avg_ns=$(( total_ns / total_gws))
26+
27+ if [ " $total_gws " -ne " $expected_count " ]; then
28+ return 1
2229 fi
30+ expected_ns_count=$(( $NVMEOF_NAMESPACES_COUNT * $NVMEOF_SUBSYSTEMS_COUNT ))
31+ if [ " $total_ns " -ne " $expected_ns_count " ]; then
32+ return 1
33+ fi
34+
35+ gateways=$( echo " $output " | jq -c ' .["Created Gateways:"][]' )
36+
37+ echo " $gateways " | while read -r gw; do
38+ gw_id=$( echo " $gw " | jq -r ' .["gw-id"]' )
39+ availability=$( echo " $gw " | jq -r ' .["Availability"]' )
40+ num_namespaces=$( echo " $gw " | jq ' .["num-namespaces"]' )
41+
42+ if [[ " $availability " != " AVAILABLE" ]]; then
43+ echo " Gateway $gw_id is not AVAILABLE."
44+ exit 1
45+ fi
46+
47+ diff=$(( num_namespaces - expected_avg_ns))
48+ if [[ $diff -lt -1 || $diff -gt 1 ]]; then
49+ echo " Gateway $gw_id has num-namespaces ($num_namespaces ), expected around $expected_ns . Indicates a problem in ns load-balancing."
50+ exit 1
51+ fi
52+ done
2353
2454 orch_ls=$( ceph orch ls)
2555 if ! echo " $orch_ls " | grep -q " $expected_count /$expected_count " ; then
0 commit comments