Skip to content

fix(ilm): parse v2 tier-stats contract in tier info - #441

Merged
cxymds merged 1 commit into
mainfrom
fix/tier-info-v2-stats
Nov 30, 2026
Merged

cxymds merged 1 commit into
mainfrom
fix/tier-info-v2-stats

Conversation

@cxymds

@cxymds cxymds commented Nov 30, 2026

Copy link
Copy Markdown
Member

Related Issues

Relates to rustfs/rustfs#9626.

Background & User Impact

Running rc bucket lifecycle tier info <TIER> <ALIAS> (or rc ilm tier info <TIER> <ALIAS>) against RustFS servers speaking the V2 /rustfs/admin/v3/tier-stats contract (introduced in rustfs/rustfs#7110) only displayed tier configuration without inventory or 24-hour transition statistics, forcing operators to hand-sign Admin API requests.

Root Cause

execute_info in crates/cli/src/commands/ilm/tier.rs called GET /tier-stats without a tier query parameter and looked up stats.get(&tier_name) at the top level of the JSON object. Because the V2 response uses an envelope ({ contractVersion, inventory, activity, tiers: [...] }) instead of the legacy V1 top-level map, the lookup always returned None, and request errors were silently swallowed into None.

Solution

  • Updated AdminApi::tier_stats (crates/core/src/admin/mod.rs) and AdminClient::tier_stats (crates/s3/src/admin.rs) to accept an optional tier filter (GET /tier-stats?tier=<TIER>).
  • Added typed V2 /tier-stats parsing in crates/cli/src/commands/ilm/tier.rs with case-insensitive tier matching and backward-compatible V1 top-level map fallback.
  • Separated Inventory (cluster-wide) and Transitions (last 24h) in both human-readable and --json outputs:
    • Never fabricates 0 when inventory.status is not-accounted / unavailable or when no inventory entry exists for the tier yet.
    • Reports partial node coverage (nodesReporting/nodesExpected and unavailableNodes) for 24-hour transitions.
    • Surfaces request/parse failures via statsError (JSON) and Stats: unavailable (...) (text) instead of silently hiding them.
  • Added unit tests covering V2 accounted, V2 not-accounted + partial activity, V2 accounted without tier entry, V1 legacy fallback, and malformed payload error reporting.

Validation

  • cargo fmt --all --check — passed
  • cargo clippy --workspace -- -D warnings — passed (0 warnings)
  • cargo test --workspace — all unit, integration, and doc tests passed

@cxymds
cxymds merged commit 3195dd9 into main Nov 30, 2026
14 checks passed
@cxymds
cxymds deleted the fix/tier-info-v2-stats branch November 30, 2026 08:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant