Skip to content

B2-3: Add objectfs cluster status subcommand #147

Closed

Description

@scttfrdmn

Summary

Add objectfs cluster status subcommand that queries the running ObjectFS instance's health endpoint and displays cluster state in human-readable or JSON format.

Background

Operators need a way to quickly assess cluster health without parsing logs or writing curl commands. This subcommand follows the same pattern as etcdctl endpoint status and consul members.

Implementation

cmd/objectfs/main.go — add cluster subcommand with nested status:

objectfs cluster status [--json] [--endpoint http://localhost:8081]

Connects to the health endpoint (default http://localhost:8081/health/cluster), displays:

ObjectFS Cluster Status
=======================
Node:    node-1 (this node)
Role:    Leader
Address: 10.0.1.1:7946

Peers (3 alive, 0 suspect, 0 dead):
  node-2  10.0.1.2:7946  alive   leader=false  cache_hit=84%
  node-3  10.0.1.3:7946  alive   leader=false  cache_hit=71%

Cache:
  Hit rate:   78%
  Size:       12.4 GB / 20 GB

Top 5 keys by access:
  genomics/sample-42/reads.bam  (1,204 reads in last 5m)
  genomics/reference/hg38.fa    (892 reads in last 5m)
  ...

With --json:

{
  "node_id": "node-1",
  "role": "leader",
  "peers": [...],
  "cache": {...},
  "top_keys": [...]
}

Exit codes:

  • 0: healthy, quorum present
  • 1: instance unreachable OR quorum lost

Health endpoint changes

Extend internal/health/ to expose /health/cluster endpoint returning the cluster status JSON payload.

Acceptance Criteria

  • Human-readable output includes all fields listed above
  • --json flag produces valid JSON
  • Exit code 1 when instance is not running
  • Exit code 1 when quorum is lost (fewer than majority alive)
  • go test ./cmd/objectfs/... passes

Dependencies

  • Requires B1-1 (subcommand routing in main.go)

Activity

  1. added
    type: enhancement
    priority: medium
    area: core
    on Apr 7, 2026
  2. scttfrdmn commented on Jul 30, 2026

    @scttfrdmn
    OwnerAuthor

    Correction: mislabeled track, and three of the four data fields do not exist

    Filing note from the v0.10.0 review — the premises here need adjusting before anyone starts.

    This is distributed work, not packaging work. Filed under Track B (install/ops), but every field the subcommand needs to display comes from internal/distributed. It cannot be implemented without the consensus/cluster layer being live in the process.

    Blocking dependencies not currently listed. The issue lists only #134.

    Suggested adjustment

    1. Re-label to area: distributed (keep type: enhancement).
    2. Add A2-1: Wire ClusterManager into Adapter and FileSystem #139 and A1-5: Populate NodeInfo stats via gossip heartbeat #132 as explicit dependencies.
    3. Either drop "top keys by access" from the acceptance criteria, or split it into its own issue against the cache package — it is the largest piece of work in this issue and is currently invisible in the scope.

    The remaining fields (node ID, status, addresses) are genuinely reachable once #139 lands, so the subcommand is worth keeping as-is otherwise.

  3. scttfrdmn commented on Aug 2, 2026

    @scttfrdmn
    OwnerAuthor

    Correction: this is distributed work filed as CLI work, and most of what it displays does not exist

    Re-verified against main. The subcommand is a thin shell; everything behind it is unbuilt, and the issue's framing hides that.

    1. There is no /health/cluster endpoint, and no cluster-aware health surface at all. internal/health/checker.go:145 registers exactly one path, /health (:474). The issue mentions extending internal/health/ in a one-line aside under "Health endpoint changes" — but that extension is the whole feature. The CLI is http.Get plus formatting.

    2. Every field in the sample output depends on unlanded issues:

    output field requires
    Role: Leader, leader=false leadership that reflects real state — ClusterManager.IsLeader exists, but broadcastProposal (consensus.go:754-759) self-accepts proposals in simulation, so leadership is not a cluster fact yet (#133)
    Peers (3 alive, 0 suspect, 0 dead) #132 — NodeInfo stats are not populated by gossip
    cache_hit=84% per peer #132. NodeInfo.CacheHitRate exists (cluster.go:85) and calculateClusterStats averages it (:532-551), but nothing ever writes a nonzero value into a peer's copy
    Top 5 keys by access #140 — the KeyAnnouncement map does not exist; no per-key access counters exist anywhere
    Cache: 12.4 GB / 20 GB available today

    So of the four display blocks, one is implementable now.

    3. "Exit code 1 when quorum is lost" is not decidable from current state. Quorum requires knowing the configured member set and which members are alive. Alive-ness is #132. Without it the check degrades to "how many nodes are in my local map", which after a partition is exactly the number that makes a minority believe it has quorum.

    4. Relabel. This is area: distributed, not area: core, and its dependency list should read #132, #140, and #134 — not #134 alone. As filed under a packaging-adjacent title it reads like an afternoon of CLI work; it is the observability surface for the entire distributed layer and cannot ship ahead of it.

    Suggested split, so something useful can land early:

    Accurate as written: the etcdctl endpoint status / consul members precedent is the right model, --json alongside human output is right, and distinguishing exit code 0 from 1 on quorum rather than only on reachability is the correct instinct once quorum is knowable.

  4. added
    effort: small
    on Aug 3, 2026
  5. scttfrdmn commented on Aug 9, 2026

    @scttfrdmn
    OwnerAuthor

    Scoping note before implementation: the endpoint this issue specifies does not exist.

    The body says the subcommand reads http://localhost:8081/health/cluster. internal/health/checker.go registers exactly one handler, at c.config.HTTPPath — default /health (checker.go:192, :605) — and grepping internal/health/ for "cluster" returns nothing outside tests. The health package knows nothing about clustering, so this issue as written is a client for a server that was never built.

    So the work is two halves, server first: publish cluster state from the accessors ClusterManager already has (GetNodeID, GossipAddr, GetNodes, GetStats, IsLeader, GetLeader — cluster.go:413-490), then the subcommand that reads it.

    Second scoping note, on the mockup: it shows leader=false per peer, per-peer cache_hit=%, and a "Top 5 keys by access" section. Each needs verifying as populated before it is displayed. IsLeader in particular will be false on every node, because v0.13.0 deliberately does not start consensus on the mount path — coordination is compare-and-swap, not Raft — so printing Role: Follower for a healthy single-node cluster would be misleading. A field that is not measured must not print as a zero: that is #222 (percentiles declared, never assigned, published as zeros) repeated in a new place.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: coreeffort: smallpriority: mediumtype: enhancement

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions