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
- func ParseEnvironmentFile(data []byte) (map[string]string, error)
- type Config
- type ExportRequest
- type Host
- func (h *Host) Complete(ctx context.Context) error
- func (h *Host) Config() Config
- func (h *Host) ConfigureRuntime(ctx context.Context, e RuntimeEvidence) error
- func (h *Host) Environment() map[string]string
- func (h *Host) Export(ctx context.Context, candidate string, request ExportRequest) ([]byte, error)
- func (h *Host) FenceAndStop(ctx context.Context) error
- func (h *Host) InstallBinary(ctx context.Context, candidate, digest string) error
- func (h *Host) Maintenance() (bool, error)
- func (h *Host) Migrate(ctx context.Context, candidate string, e RuntimeEvidence) ([]byte, error)
- func (h *Host) Preflight(ctx context.Context) error
- func (h *Host) PrepareDirectories() error
- func (h *Host) PreparePublicOutput(name string) (string, error)
- func (h *Host) PruneCandidates() error
- func (h *Host) PrunePublic(keep RuntimeEvidence) error
- func (h *Host) PublishPublicEvidence(name string, raw []byte) (string, error)
- func (h *Host) RunOperator(ctx context.Context, args []string, stdin io.Reader, stdout, stderr io.Writer) error
- func (h *Host) RuntimeGID() int
- func (h *Host) RuntimeUID() int
- func (h *Host) StageCandidate(source, digest string) (string, error)
- func (h *Host) StagePublicBundle(source string) (string, error)
- func (h *Host) StartCandidate(ctx context.Context, digest string, requireReady bool, timeout time.Duration) (err error)
- type RuntimeEvidence
Constants ¶
const ConfigPath = "/etc/hikyo/upgrade.json"
Variables ¶
This section is empty.
Functions ¶
func ParseEnvironmentFile ¶
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 ¶
InitializeConfig creates the default configuration once, without replacing existing operator configuration. It does not start or stop the deployment.
func LoadConfig ¶
LoadConfig refuses unknown fields, symbolic links, and writable authority.
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 (*Host) Complete ¶
Complete may only be called after the coordinator validates the exact final database identity and healthy phase. It never performs a rollback.
func (*Host) ConfigureRuntime ¶
func (h *Host) ConfigureRuntime(ctx context.Context, e RuntimeEvidence) error
func (*Host) Environment ¶
func (*Host) FenceAndStop ¶
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 (*Host) Maintenance ¶
func (*Host) Preflight ¶
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 (*Host) PreparePublicOutput ¶
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 ¶
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 (*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 (*Host) RuntimeUID ¶
func (*Host) StagePublicBundle ¶
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.