fix: generate random machine ids to prevent fleet state clobbering#12
Open
paddo wants to merge 4 commits into
Open
fix: generate random machine ids to prevent fleet state clobbering#12paddo wants to merge 4 commits into
paddo wants to merge 4 commits into
Conversation
A machine_id is derived from hostname, so onboarding a machine that shares a hostname reused an existing machines/<id>.json record. The new machine's first sync overwrote it with empty local state, which detect_removed_packages then flagged as deliberate removals across the fleet. init now detects an existing machine record before the first sync and asks whether it is the same machine or a new one, assigning a unique id when new. Also surface pnpm errors written to stdout: pnpm exits non-zero with the message on stdout, so failures previously showed a blank reason.
Deriving machine_id from the hostname meant two machines sharing a hostname also shared a machines/<id>.json record — the second machine's sync overwrote the first's state. The previous interactive collision check only narrowed the window and still mishandled a genuinely re-onboarded machine. machine_id is now a random hex id minted once per machine. Collisions are no longer possible and the hostname is purely display metadata on MachineState. Existing machines keep their hostname-based id since it is already persisted in state.json.
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.
Summary
machine_idwas derived from the hostname, so two machines sharing a hostname also shared amachines/<id>.jsonrecord. The second machine's first sync overwrote the first's state with empty local data, and removed-package detection then flagged the whole fleet's packages as deliberately removed.machine_idis now a random hex id minted once per machine. Collisions are no longer possible; the hostname is purely display metadata onMachineState. Existing machines keep their hostname-based id (already persisted instate.json), so there is no migration.tether machines remove) rather than risking a clobber.Test plan
tether initmints a randommachine_id; a second machine with the same hostname gets a distinct id and does not overwrite the first's recordtether machines list/removestill work with the new ids