HydraIssues

hydranode install writes a 0-byte body.yaml, then mirrors the empty file over the good backup
open unclassified Project: hydranode Reporter: 14 Oct 2026 22:39

Description

Found 2026-10-14 provisioning a fresh Windows body (#708). Reproducible and destructive.

Symptoms, in order

  1. hydranode install --server ... --token ... run as SYSTEM reports success:
    Config written to C:\Windows\system32\config\systemprofile\.hydranode\body.yaml
    Backup config written to C:\hydranode\body.yaml
  2. The PRIMARY is 0 bytes. The BACKUP is correct (146 bytes).
  3. hydranode itself works anyway: it falls back to the backup and heartbeats online. So nothing looks wrong from the cluster side.
  4. hydrabody then cannot start: it reads the shared primary, finds it empty, and exits with Error: --server is required. hydrabody has no backup fallback.
  5. Worse, some time later the BACKUP is also 0 bytes. The good copy is gone. Verified: it was 146 bytes at 22:16 and 0 bytes at 22:33, with only hydranode running in between. The mirror path propagated the empty primary over the backup that existed to protect against exactly this.

What is NOT the cause

  • The directory is writable: a probe file written to the same directory persisted fine (18 bytes).
  • Not filesystem redirection: PowerShell reported Is64BitProcess=True, $PSHOME under System32, and no SysWOW64 copy of the file exists.
  • Not a later rewrite of a good file: a Copy-Item of the backup onto the primary read back as 0 bytes IMMEDIATELY, because by then the backup was already empty too.

Where to look

internal/cli/body/install.go marshals the config once and writes the same data to both paths, so the data was never empty at that point. Suspect the post-install path: pkg/body/service_windows.go copySharedConfig() reads b.DataDir/body.yaml and writes to C:\Windows\System32\config\systemprofile\.hydranode\body.yaml. When the agent runs as SYSTEM those are the SAME FILE, so it is a self-copy, and whatever makes it read empty then writes empty back. The mirror-on-read path referenced in install.go's comment is the likely route by which the emptiness reaches the backup.

Workaround that works

Write both files directly, not with Copy-Item (the source may already be empty):

$c = "server_url: https://hydracluster.experiencenet.com`ntoken: <token>`nrecovery_reboot: false`n"
[System.IO.File]::WriteAllText("C:\Windows\System32\config\systemprofile\.hydranode\body.yaml", $c)
[System.IO.File]::WriteAllText("C:\hydranode\body.yaml", $c)

After that hydrabody starts and the file stays at 146 bytes.

Why it matters beyond the cloud

Any newly provisioned Windows body hits this. hydranode comes up and looks healthy, so the failure presents much later as "hydrabody will not start" with a misleading message about a missing flag. hydranode status also reads the empty primary and prints a blank Server line while the agent is in fact connected, which sends you looking in the wrong place.

Related: #708, #146 (the backup exists because of a previous SYSTEM-profile loss).