update

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2026 License: AGPL-3.0 Imports: 24 Imported by: 0

Documentation

Overview

Package update replaces the running Zelie with a signed release. The core fetches and checks the release; a short-lived systemd unit, run from the binary being replaced, restarts the services and puts the old binary back if the new one does not come up.

Index

Constants

View Source
const (
	Old       = install.Binary + ".old"
	StateFile = "/var/lib/zelie/update.json"
	// Unit is the transient systemd unit that finishes an update. Its
	// fixed name also keeps two updates from running at once.
	Unit = "zelie-update"
	// HealthTimeout is how long the new version has to come up.
	HealthTimeout = 90 * time.Second
)

The binary being replaced is kept next to the new one until the next update, for the rollback. Going back by hand needs the panel's database from before the update as well, and that copy does not outlive the update.

View Source
const DBCopy = "/var/lib/zelie/panel.db.before-update"

The new version migrates the panel's database as soon as it starts, and a version that finds a schema newer than the one it knows refuses to open it. An update that goes back would then bring up a panel that cannot start. So the update keeps a copy of the database from before the new version ran and puts it back with the old binary. DBCopy is where it waits, out of the panel's own directory.

View Source
const Repo = "Caria-Core/zelie"

Repo is where releases are published.

Variables

This section is empty.

Functions

func Newer

func Newer(a, b string) bool

Newer reports whether version a comes after b. A build that is not a release, such as "dev", is never older than anything: it cannot be told what it would be updated to.

func ParseKey

func ParseKey(data []byte) (ed25519.PublicKey, error)

ParseKey reads an Ed25519 public key in PEM, as openssl writes it.

func Place

func Place(root string, bin []byte) error

Place puts bin where the services run from, keeping the current binary as Old. Root is prepended to the paths; empty on a server.

func Revert added in v0.7.14

func Revert(root string) error

Revert puts Old back as the binary the services run from, for an update that did not come up or could not be started at all.

func Started

func Started(root, from, to string, now time.Time) error

Started records that an update is under way, before the unit runs.

func Valid

func Valid(v string) bool

Valid reports whether v is a release version such as v1.2.3.

Types

type Fetcher

type Fetcher struct {
	Client *http.Client
	// Base is where release files are, with the version appended; tests
	// point it at a local server.
	Base string
	// Key replaces the embedded public key in tests.
	Key ed25519.PublicKey
}

Fetcher downloads releases.

func (*Fetcher) Binary

func (f *Fetcher) Binary(ctx context.Context, version, arch string) ([]byte, error)

Binary downloads the release's binary for arch and returns it once its checksum matches the signed list.

type Finisher

type Finisher struct {
	Root string
	Exec func(ctx context.Context, name string, args ...string) (string, error)
	// Healthy reports whether every service answers with version.
	Healthy func(ctx context.Context, version string) error
	Timeout time.Duration
	Now     func() time.Time
}

Finisher restarts the services on the new binary and checks that they come up. It runs from Old, so a new binary that does not even start cannot keep the old one from coming back.

func (*Finisher) Run

func (f *Finisher) Run(ctx context.Context, from, to string) Result

Run finishes the update from one version to another and records how it went.

type Result

type Result struct {
	From    string `json:"from"`
	To      string `json:"to"`
	Running bool   `json:"running,omitempty"`
	OK      bool   `json:"ok"`
	// Reason is why the update failed and Back what became of the old
	// version, for the web interface to say in the user's language. Error
	// is both in English, as earlier versions saved it.
	Reason *msg.Msg  `json:"reason,omitempty"`
	Back   *msg.Msg  `json:"back,omitempty"`
	Error  string    `json:"error,omitempty"`
	At     time.Time `json:"at"`
}

Result is the outcome of the last update, as the panel shows it.

func Last

func Last(root string) (Result, error)

Last reads the outcome of the last update, if there was one.

Jump to

Keyboard shortcuts

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