From 3926d108f27e07d15b76e5992116df121b304cf4 Mon Sep 17 00:00:00 2001 From: overtrue Date: Sat, 1 Aug 2026 10:40:16 +0800 Subject: [PATCH] fix(kms): report real cache counters through the admin status API KmsStatusResponse.cache_stats mapped the old (entry_count, 0) tuple onto hit_count and miss_count, so operators polling KMS status read the entry count as a hit count and a miss count that was always zero. Map the fields to the counters they claim to be, and add entry_count and eviction_count as additive, defaulted fields so the entry number that hit_count used to carry is still available. Refs rustfs/backlog#1584 --- rustfs/src/admin/handlers/kms_management.rs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/rustfs/src/admin/handlers/kms_management.rs b/rustfs/src/admin/handlers/kms_management.rs index 88ee3a6f9..7fa45b372 100644 --- a/rustfs/src/admin/handlers/kms_management.rs +++ b/rustfs/src/admin/handlers/kms_management.rs @@ -82,6 +82,14 @@ pub struct KmsStatusResponse { pub struct CacheStatsResponse { pub hit_count: u64, pub miss_count: u64, + /// Entries currently cached. Additive field: omitted by older servers, so + /// it must stay defaulted for consumers. + #[serde(default)] + pub entry_count: u64, + /// Entries dropped since process start, whatever the cause. Additive + /// field, same compatibility rule as `entry_count`. + #[serde(default)] + pub eviction_count: u64, } #[derive(Debug, Serialize, Deserialize)] @@ -193,9 +201,11 @@ impl Operation for KmsStatusHandler { } }; - let cache_stats = service.cache_stats().await.map(|(hits, misses)| CacheStatsResponse { - hit_count: hits, - miss_count: misses, + let cache_stats = service.cache_stats().await.map(|stats| CacheStatsResponse { + hit_count: stats.hits, + miss_count: stats.misses, + entry_count: stats.entries, + eviction_count: stats.evictions, }); let config = kms_service_manager_from_context().get_redacted_config().await;