hostupgrade

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2026 License: MPL-2.0 Imports: 27 Imported by: 0

Documentation

Overview

Package hostupgrade provides the bounded, operator-invoked systemd adapter. It never accepts a shell command, service name, or destination from a release.

Index

Constants

View Source
const ConfigPath = "/etc/hikyo/upgrade.json"

Variables

This section is empty.

Functions

func ParseEnvironmentFile

func ParseEnvironmentFile(data []byte) (map[string]string, error)

ParseEnvironmentFile implements a deliberately bounded subset of systemd EnvironmentFile syntax: one assignment per line, optional whole-value quotes, no continuations or escapes. Unsupported syntax fails instead of being interpreted differently by the updater and the service. No shell is used.

Types

type Config

type Config struct {
	Unit                  string `json:"unit"`
	User                  string `json:"user"`
	Group                 string `json:"group"`
	WorkingDirectory      string `json:"working_directory"`
	EnvironmentFile       string `json:"environment_file"`
	RootKeyFile           string `json:"root_key_file"`
	Binary                string `json:"binary"`
	HealthURL             string `json:"health_url"`
	PublicDirectory       string `json:"public_directory"`
	InstallationDirectory string `json:"installation_directory"`
	StateDirectory        string `json:"state_directory"`
	CustodyDirectory      string `json:"custody_directory"`
	CandidateDirectory    string `json:"candidate_directory"`
	Principal             string `json:"principal,omitempty"`
	Project               string `json:"project,omitempty"`
}

Config is operator-owned deployment configuration, never release metadata.

func DefaultConfig

func DefaultConfig() Config

func InitializeConfig

func InitializeConfig(path string) (Config, error)

InitializeConfig creates the default configuration once, without replacing existing operator configuration. It does not start or stop the deployment.

func LoadConfig

func LoadConfig(path string) (Config, error)

LoadConfig refuses unknown fields, symbolic links, and writable authority.

func (Config) Validate

func (c Config) Validate() error

type ExportRequest

type ExportRequest struct {
	OutputDirectory string
	Recipient       string
	Runtime         RuntimeEvidence
}

type Host

type Host struct {
	// contains filtered or unexported fields
}

Host exposes fixed deployment operations only. Root-owned configuration is authoritative. The caller must authenticate releases and drive a durable journal before any migration operation.

func New

func New(c Config) (*Host, error)

func (*Host) Complete

func (h *Host) Complete(ctx context.Context) error

Complete may only be called after the coordinator validates the exact final database identity and healthy phase. It never performs a rollback.

func (*Host) Config

func (h *Host) Config() Config

func (*Host) ConfigureRuntime

func (h *Host) ConfigureRuntime(ctx context.Context, e RuntimeEvidence) error

func (*Host) Environment

func (h *Host) Environment() map[string]string

func (*Host) Export

func (h *Host) Export(ctx context.Context, candidate string, request ExportRequest) ([]byte, error)

func (*Host) FenceAndStop

func (h *Host) FenceAndStop(ctx context.Context) error

FenceAndStop first records maintenance and a persistent systemd condition, then stops the whole control group. Reboot cannot resurrect the old writer.

func (*Host) InstallBinary

func (h *Host) InstallBinary(ctx context.Context, candidate, digest string) error

func (*Host) Maintenance

func (h *Host) Maintenance() (bool, error)

func (*Host) Migrate

func (h *Host) Migrate(ctx context.Context, candidate string, e RuntimeEvidence) ([]byte, error)

func (*Host) Preflight

func (h *Host) Preflight(ctx context.Context) error

Preflight is read-only and must run before maintenance. PostgreSQL and HA require a deployment-wide writer proof this single-unit adapter cannot give.

func (*Host) PrepareDirectories

func (h *Host) PrepareDirectories() error

func (*Host) PreparePublicOutput

func (h *Host) PreparePublicOutput(name string) (string, error)

PreparePublicOutput gives the runtime an empty leaf for backup export. Its root-owned parent prevents renaming another upgrade's evidence into place.

func (*Host) PruneCandidates

func (h *Host) PruneCandidates() error

PruneCandidates removes every staged candidate executable. InstallBinary copies the chosen candidate into place, so after a completed upgrade the staging copies are dead weight of over 100 MiB each.

func (*Host) PrunePublic

func (h *Host) PrunePublic(keep RuntimeEvidence) error

PrunePublic removes the bundle-*, evidence-* and backup-* directories that earlier upgrade runs left under the public directory, keeping only the entries the given evidence still references. The caller passes the journal of the run that just completed, so the retained encrypted backup is always the one taken before the current schema. Other names are never touched.

func (*Host) PublishPublicEvidence

func (h *Host) PublishPublicEvidence(name string, raw []byte) (string, error)

func (*Host) RunOperator

func (h *Host) RunOperator(ctx context.Context, args []string, stdin io.Reader, stdout, stderr io.Writer) error

RunOperator executes one operator verb of the installed executable the way the service itself runs: as the runtime user, in the working directory, with the unit's environment files applied in order and the configured root key on descriptor 3. Root-run host commands therefore need no hand-fed configuration. A --root-key-file argument names a private file only root can read; it is handed to the child on descriptor 4 so an escrow custody copy never has to be re-owned. The verb keeps the operator's terminal.

func (*Host) RuntimeGID

func (h *Host) RuntimeGID() int

func (*Host) RuntimeUID

func (h *Host) RuntimeUID() int

func (*Host) StageCandidate

func (h *Host) StageCandidate(source, digest string) (string, error)

func (*Host) StagePublicBundle

func (h *Host) StagePublicBundle(source string) (string, error)

StagePublicBundle copies a verified private cache into a new root-owned public directory. It never reuses a directory writable by the runtime user. The caller must verify the published bytes before admitting a migration.

func (*Host) StartCandidate

func (h *Host) StartCandidate(ctx context.Context, digest string, requireReady bool, timeout time.Duration) (err error)

StartCandidate permits this boot only. The persistent maintenance condition survives a host reboot until Complete follows the caller's exact DB check.

type RuntimeEvidence

type RuntimeEvidence struct {
	BundleDirectory      string
	OperatorPublicKey    string
	EvidenceDirectory    string
	CiphertextPath       string
	TargetManifest       string
	LegacyWritersStopped bool
}

Jump to

Keyboard shortcuts

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