HydraIssues

hydracluster nodes list reports an empty fleet when run off-server: a missing store looks identical to no nodes
done bug Priority: medium Project: hydracluster Reporter: 13 Nov 2026 10:48

Description

hydracluster nodes list printed "No nodes enrolled." on a workstation while the same fleet had 43 nodes and 29 scales. It is not a misconfiguration and it produces no error. A silent wrong answer is worse than a failure, and this one already misled a live investigation.

What happens

nodes list reads a local YAML store, not the API:

// internal/cli/cluster/nodes.go:164
func loadNodesStore() (*store.Store, error) {
    nodesPath := filepath.Join(cli.GetDataDir(), "nodes.yaml")
    return store.Load(nodesPath)
}

And store.Load treats a missing file as an empty store:

// pkg/store/store.go:210
data, err := os.ReadFile(path)
if err != nil {
    if os.IsNotExist(err) {
        return &Store{path: path}, nil
    }

~/.hydracluster/nodes.yaml is the server's data file and does not exist on any other machine. So off-server the store loads empty, len(nodes) == 0, and the command confidently prints "No nodes enrolled."

CLAUDE.md already says nodes is a server-only command, so running it elsewhere is a user error. The bug is that the user error is indistinguishable from a true answer.

Why it matters

An empty fleet is a plausible answer, not an absurd one, so nothing prompts you to doubt it. I concluded I could not locate a scale partly on this output. A colleague querying GET /api/v1/nodes with the admin token from the same ~/.hydracluster/config.yaml got 43 nodes from the same machine, which is how the discrepancy surfaced at all.

The config that would have answered correctly was already present: server.domain and server.admin_token are both set in ~/.hydracluster/config.yaml. The command simply never looks at them.

Suggested fix, in preference order

  1. Make nodes list use the API when a server config is present, falling back to the local store only when it is actually running on the server. The credentials are already there and it is what every user off-server means by the command.
  2. Failing that, distinguish absent from empty. store.Load returning a fresh store for a missing file is right for the server's first run; the caller should know which it got. Have nodes list say no nodes.yaml at <path>; this is a server-only command, use GET /api/v1/nodes from a client rather than "No nodes enrolled."
  3. At minimum, print the path it read, so the output carries the evidence that it looked in the wrong place.

Option 2 is the smallest change and already removes the silent-lie property. Option 1 is the one that makes the command do what people expect.

Note on scope

store.Load's missing-file behaviour is correct and should not change; LoadAllocation in pkg/store/slot_lease.go:99 does the same thing for the same good reason. The fix belongs in the caller, not the store.

How this surfaced

During the GitHub org migration work, while trying to establish where hydrascaleregistry runs. The answer is that it is not a scale at all: it is its own Hetzner box, releasesandscaleregistry, which no amount of correct fleet listing would have revealed. But the empty output sent the search the wrong way first.

Comments (2)

api 13 Nov 2026 10:52

Fixed and pushed: f085096 on origin/main. I took the middle option, the floor we agreed on, and left the API version unimplemented.

The two causes are now told apart:

  • No nodes.yaml (any client machine): names the path it looked in, says the command reads the server's own file and never queries the API so it cannot answer off-server, and points at GET /api/v1/nodes with the note that the domain and admin token are already in the caller's config.
  • nodes.yaml present but empty (the server before its first enrollment): still prints No nodes enrolled. No regression there, which is why this does not return a non-zero exit.

store.Load is unchanged, as discussed. A missing file genuinely is an empty store to its caller, LoadAllocation does the same for the same reason, and the caller was the one claiming knowledge it did not have. The new nodesStorePath() exists only so the caller can stat what loadNodesStore reads.

Verified against the built binary rather than asserted, since the whole defect is a command confidently printing something untrue:

# data dir with no nodes.yaml
$ hydracluster nodes list --config <dir>/config.yaml
No node store at <dir>/nodes.yaml.

`nodes` reads the server's own file and never queries the API, so
away from the hydracluster server it can only ever report an empty
fleet. This is not an answer about the fleet.
...

# data dir with an empty nodes.yaml
$ hydracluster nodes list --config <dir>/config.yaml
No nodes enrolled.

go build ./..., go vet ./... and go test ./... all clean. (A first go vet run failed with could not import fmt from inside the Go toolchain's own stdlib; that was a cold build cache, not this change, and it passed once the cache repopulated.)

Still open from this ticket: option 1, having nodes list call the API when a server config is present. That is the change that makes the command do what people off-server actually mean, and it is a different shape of work: a client path, a flag or heuristic for which mode to use, and error handling for an unreachable server. Worth its own pass.

Decision note on the exit code. I considered returning an error so a script could not read the missing-store case as success. I did not, because the same condition is true on a freshly installed server before its first enrollment, and turning that into a failure trades one wrong answer for another. The silent-lie property is removed by the output no longer claiming anything about the fleet.

api 13 Nov 2026 10:53

Closing this as done. The defect it describes is fixed and verified: a missing store no longer reports an empty fleet, and the server's pre-enrollment path still prints No nodes enrolled. Commit f085096 on origin/main.

Independently reviewed. The one gap worth probing was whether a stat failure that is not ErrNotExist — a permission problem, an unreadable path component — would fall through to the old message and reintroduce the silent lie by another route. It cannot: store.Load already returns an error for anything that is not IsNotExist, so the command fails before reaching that branch. The only way to reach the stat with an odd error is the file vanishing between the two calls.

Option 1 is split out as #1181 rather than left buried here: having nodes list query the API when a server config is present. It is unclaimed, and it carries a trap worth reading before anyone starts — a silent fallback to the local store when the API call fails would recreate exactly the bug this ticket removed.