feat(tier): report cluster tier stats and count tier requests (#7110)

`GET /v3/tier-stats` answered from whichever process received the
request, returning that node's rolling 24-hour transition counters as
if they were cluster totals, and the `TierRequestsSuccess` and
`TierRequestsFailure` metric names had no producer at all.

The body now separates the two quantities a tier carries. Stored
inventory comes from the persisted scanner usage snapshot, which is
already cluster-wide; rolling activity is summed over every member
through a new read-only `TierDailyStats` peer RPC. Rings are merged
rather than added, so an idle node's expired hours age out, and each
node counts only its own committed transitions, so a retry is counted
once. Coverage travels with the numbers: `activity.status` names the
reporting members and the ones that could not be asked, timed out, or
answered with a ring this build refuses to merge, and per-tier
inventory is absent rather than zero when the snapshot has no
accounting. The version 1 body stays reachable at `?format=legacy`.

Tier request counters are recorded at the two seams every remote
request passes through, so a new provider is counted by construction,
with a closed operation/outcome label set that can never grow a tier
name, endpoint or object key.

Closes rustfs/backlog#2207

Co-authored-by: cxymds <cxymds@gmail.com>
This commit is contained in:
Zhengchao An
2026-09-04 09:40:03 +08:00
committed by GitHub
parent 7dfc2ee5f0
commit 9863f4848d
27 changed files with 1844 additions and 46 deletions
+17
View File
@@ -1043,6 +1043,22 @@ message LoadTransitionTierConfigResponse {
optional ControlPlaneErrorCode error_code = 3;
}
message TierDailyStatsRequest {}
// One node's own rolling-day transition counters, per remote tier.
//
// `tier_daily_stats` is a msgpack map of tier name to the responder's 24-bin
// ring plus the clock that ring was last aged to. A node counts only the
// transitions it completed itself, so a caller sums the rings of every node to
// obtain a cluster total. A peer that does not implement this RPC answers
// UNIMPLEMENTED, which the caller reports as a non-reporting node rather than
// as zero activity.
message TierDailyStatsResponse {
bool success = 1;
bytes tier_daily_stats = 2;
optional string error_info = 3;
}
message TierMutationPrepareRequest {
uint32 version = 1;
string mutation_id = 2;
@@ -1203,6 +1219,7 @@ service NodeService {
rpc CancelDecommission(CancelDecommissionRequest) returns (CancelDecommissionResponse) {}; // auth-policy: body-bound
rpc ClearDecommission(ClearDecommissionRequest) returns (ClearDecommissionResponse) {}; // auth-policy: body-bound
rpc LoadTransitionTierConfig(LoadTransitionTierConfigRequest) returns (LoadTransitionTierConfigResponse) {}; // auth-policy: body-bound
rpc TierDailyStats(TierDailyStatsRequest) returns (TierDailyStatsResponse) {}; // auth-policy: read-only
rpc GetLiveEvents(GetLiveEventsRequest) returns (GetLiveEventsResponse) {}; // auth-policy: read-only
}