Repository navigation
Keep --host-name from an applied set in the state dir (#98) - #99
Merged
Merged
Conversation
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
marked this pull request as ready for review
November 12, 2026 20:55
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.flagsis shared by every host's daemon, so it cannotname one host among several. When a deploy applies a set carrying
--host-name(allowed only while the fleet has that single host), the daemonnow keeps it in
<state-dir>/host-name;Mergetreats the file like theunit flag (unit wins, kept wins over later sets).
Fixes #98.
What changed
pkg/serveflags/serveflags.go: newHostNameFileName,keptHostNamereader (empty or multi-word files are ignored, never guessed from),
PersistHostNamewriter (unit flag present, or missing/multi-word setname, means nothing to keep),
Mergefalls back to the kept name when theunit has none.
cmd/native-ops/serve.go: after a managed set is applied, persist itshost 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 -lclean repo-wide,go vet ./...clean,go build ./...clean,go test -racegreen onpkg/serveflags,pkg/config,cmd/native-ops.Rollback
Delete
<state-dir>/host-nameand the daemon falls back to exactly the oldbehavior (unit flag, then the set's). No migration, no config change.