From 24e7075f08cf616d22c1def661f15007cd94069b Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Sun, 28 Feb 2021 19:51:14 +0300 Subject: [PATCH] Fix monitor's statistics aggregation --- mon/mon.js | 16 ++++++++-------- tests/test_change_pg_count.sh | 10 ++++++++-- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/mon/mon.js b/mon/mon.js index 743f675a..d817bbf5 100644 --- a/mon/mon.js +++ b/mon/mon.js @@ -379,7 +379,7 @@ class Mon } if (this.verbose) { - console.log(e); + console.log(JSON.stringify(e)); } } if (stats_changed) @@ -974,21 +974,21 @@ class Mon for (const op in st.op_stats||{}) { op_stats[op] = op_stats[op] || { count: 0n, usec: 0n, bytes: 0n }; - op_stats[op].count += BigInt(st.op_stats.count||0); - op_stats[op].usec += BigInt(st.op_stats.usec||0); - op_stats[op].bytes += BigInt(st.op_stats.bytes||0); + op_stats[op].count += BigInt(st.op_stats[op].count||0); + op_stats[op].usec += BigInt(st.op_stats[op].usec||0); + op_stats[op].bytes += BigInt(st.op_stats[op].bytes||0); } for (const op in st.subop_stats||{}) { subop_stats[op] = subop_stats[op] || { count: 0n, usec: 0n }; - subop_stats[op].count += BigInt(st.subop_stats.count||0); - subop_stats[op].usec += BigInt(st.subop_stats.usec||0); + subop_stats[op].count += BigInt(st.subop_stats[op].count||0); + subop_stats[op].usec += BigInt(st.subop_stats[op].usec||0); } for (const op in st.recovery_stats||{}) { recovery_stats[op] = recovery_stats[op] || { count: 0n, bytes: 0n }; - recovery_stats[op].count += BigInt(st.recovery_stats.count||0); - recovery_stats[op].bytes += BigInt(st.recovery_stats.bytes||0); + recovery_stats[op].count += BigInt(st.recovery_stats[op].count||0); + recovery_stats[op].bytes += BigInt(st.recovery_stats[op].bytes||0); } } for (const op in op_stats) diff --git a/tests/test_change_pg_count.sh b/tests/test_change_pg_count.sh index c7eedf2c..254edab3 100755 --- a/tests/test_change_pg_count.sh +++ b/tests/test_change_pg_count.sh @@ -25,7 +25,7 @@ OSD6_PID=$! cd mon npm install cd .. -node mon/mon-main.js --etcd_url http://$ETCD_URL --etcd_prefix "/vitastor" &>./testdata/mon.log & +node mon/mon-main.js --etcd_url http://$ETCD_URL --etcd_prefix "/vitastor" --verbose 1 &>./testdata/mon.log & MON_PID=$! $ETCDCTL put /vitastor/config/pools '{"1":{"name":"testpool","scheme":"replicated","pg_size":2,"pg_minsize":1,"pg_count":16,"failure_domain":"osd"}}' @@ -97,9 +97,15 @@ try_change 17 try_change 16 +# Monitor should report non-zero overall statistics at least once + +if ! (grep /vitastor/stats ./testdata/mon.log | jq -s -e '[ .[] | select((.kv.value.op_stats.primary_write.count | tonumber) > 0) ] | length > 0'); then + format_error "FAILED: monitor doesn't aggregate stats" +fi + # Changing pg count should never produce the 'has_degraded' object state -if grep has_degraded testdata/osd*.log; then +if grep has_degraded ./testdata/osd*.log; then format_error "FAILED: some objects were degraded during PG move" fi