Skip to content

Keep --host-name from an applied set in the state dir (#98) - #99

Merged
wmantly merged 1 commit into
mainfrom
host-name-persist
Nov 12, 2026
Merged

wmantly merged 1 commit into
mainfrom
host-name-persist

Conversation

@wmantly

@wmantly wmantly commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

Keep --host-name from an applied set in the state dir

Summary

An existing host's daemon has no lasting name via GitOps: the unit flag is
hand work, and daemon.flags is shared by every host's daemon, so it cannot
name one host among several. When a deploy applies a set carrying
--host-name (allowed only while the fleet has that single host), the daemon
now keeps it in <state-dir>/host-name; Merge treats the file like the
unit flag (unit wins, kept wins over later sets).

Fixes #98.

What changed

  • pkg/serveflags/serveflags.go: new HostNameFileName, keptHostName
    reader (empty or multi-word files are ignored, never guessed from),
    PersistHostName writer (unit flag present, or missing/multi-word set
    name, means nothing to keep), Merge falls back to the kept name when the
    unit has none.
  • cmd/native-ops/serve.go: after a managed set is applied, persist its
    host name (when the unit has none) and log it; a write failure is logged,
    never fatal.
  • pkg/serveflags/serveflags_test.go: TestMergeKeepsAHostNameFromTheStateDirFile
    (precedence unit > kept > set; empty/multi-word ignored),
    TestPersistHostNameWritesTheSetsName (write and skip cases).

Verification

New tests fail before the change (undefined symbols) and pass after.
gofmt -l clean repo-wide, go vet ./... clean, go build ./... clean,
go test -race green on pkg/serveflags, pkg/config, cmd/native-ops.

Rollback

Delete <state-dir>/host-name and the daemon falls back to exactly the old
behavior (unit flag, then the set's). No migration, no config change.

A daemon learns which host it is only from --host-name on its unit or from
daemon.flags, which every host's daemon shares. When a deploy applies a set
carrying --host-name (allowed only while the fleet has that single host), the
daemon now keeps the name in <state-dir>/host-name. Merge treats the file like
the unit flag: the unit's own flag wins, and the kept name wins over later sets.
An empty or multi-word file is ignored, never guessed from.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

@wmantly wmantly left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGMT

@wmantly
wmantly marked this pull request as ready for review November 12, 2026 20:55
@wmantly
wmantly merged commit a3dd9f7 into main Nov 12, 2026
2 checks passed
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.

Existing host's daemon has no lasting name via GitOps

1 participant