reinstall

package
v1.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 25, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package reinstall implements the daemon's reinstall-handoff checkpoint.

Lifecycle:

  1. PrepareReinstall RPC writes a JSON checkpoint listing every running go-exec target (target ID, mode, env). Containers aren't listed — they survive the daemon's death anyway.
  2. Daemon exits cleanly; go-exec children receive SIGTERM via the normal Kill path.
  3. Install script overwrites the binary.
  4. New daemon starts, observes the checkpoint at well-known path, re-launches the listed go-exec targets, deletes the checkpoint.

The checkpoint is single-purpose handoff state — the daemon's correctness doesn't depend on it (missing checkpoint = degraded behavior, not broken behavior). This preserves the daemon's stateless-recovery principle.

Index

Constants

View Source
const SchemaVersion = 1

SchemaVersion is bumped when Checkpoint's shape changes. An older daemon reading a newer schema (or vice versa) silently discards the checkpoint — handoff degrades gracefully rather than fails.

Variables

This section is empty.

Functions

func Delete

func Delete() error

Delete removes the checkpoint. Idempotent.

func EnsureSinglePending

func EnsureSinglePending() error

EnsureSinglePending guards against double-checkpoint races. If the checkpoint already exists when a new PrepareReinstall arrives, returns an error rather than overwriting (the caller is responsible for resolving — typically by aborting the second install).

func Exists

func Exists() bool

Exists reports whether the checkpoint file is present. Cheap — used by Status to surface "reinstall pending".

func Path

func Path() string

Path returns the canonical checkpoint location.

func Write

func Write(cp Checkpoint) error

Write serializes cp to Path(), fsync'd. Atomic via tmp+rename so a crash between write and rename doesn't leave a corrupt file. Stamps the schema + timestamp itself.

Types

type Checkpoint

type Checkpoint struct {
	Schema    int                `json:"schema"`
	WrittenAt time.Time          `json:"written_at"`
	GoExec    []GoExecCheckpoint `json:"go_exec"`
}

Checkpoint is the JSON document persisted between daemon invocations.

func Read

func Read() (*Checkpoint, error)

Read returns the checkpoint at Path(), or (nil, nil) if no checkpoint exists (the common case at every fresh start). A schema mismatch or malformed file is returned as (nil, nil) — handoff degrades to "containers survive, go-exec targets are lost" rather than failing the daemon's startup.

type GoExecCheckpoint

type GoExecCheckpoint struct {
	TargetID string   `json:"target_id"`
	Env      []string `json:"env"`
}

GoExecCheckpoint is one running go-exec target's relaunch payload. Container targets are NOT recorded — podman keeps them alive across daemon restarts, and adoption (a separate phase 3 follow-up) picks them up.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL