From d007a374f239f1b87e9a85658df15a8e51a629df Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Thu, 6 Jul 2023 00:40:13 +0300 Subject: [PATCH] Delete extra /pool/stats/ keys for non-existing pools --- mon/mon.js | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/mon/mon.js b/mon/mon.js index 8f227948..bde52e6b 100644 --- a/mon/mon.js +++ b/mon/mon.js @@ -1608,7 +1608,7 @@ class Mon } } } - return inode_stats; + return { inode_stats, seen_pools }; } serialize_bigints(obj) @@ -1634,7 +1634,7 @@ class Mon const timestamp = Date.now(); const { object_counts, object_bytes } = this.sum_object_counts(); let stats = this.sum_op_stats(timestamp, this.prev_stats); - let inode_stats = this.sum_inode_stats( + let { inode_stats, seen_pools } = this.sum_inode_stats( this.prev_stats ? this.prev_stats.inode_stats : null, timestamp, this.prev_stats ? this.prev_stats.timestamp : null ); @@ -1669,12 +1669,22 @@ class Mon } for (const pool_id in this.state.pool.stats) { - const pool_stats = { ...this.state.pool.stats[pool_id] }; - this.serialize_bigints(pool_stats); - txn.push({ requestPut: { - key: b64(this.etcd_prefix+'/pool/stats/'+pool_id), - value: b64(JSON.stringify(pool_stats)), - } }); + if (!seen_pools[pool_id]) + { + txn.push({ requestDeleteRange: { + key: b64(this.etcd_prefix+'/pool/stats/'+pool_id), + } }); + delete this.state.pool.stats[pool_id]; + } + else + { + const pool_stats = { ...this.state.pool.stats[pool_id] }; + this.serialize_bigints(pool_stats); + txn.push({ requestPut: { + key: b64(this.etcd_prefix+'/pool/stats/'+pool_id), + value: b64(JSON.stringify(pool_stats)), + } }); + } } if (txn.length) {