fleetdriver

package
v0.16.355 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: AGPL-3.0 Imports: 14 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package fleetdriver rolls one runtime release out to a list of machines in waves: it uploads the tarball, stages it everywhere first (nothing that runs changes), then activates the machines wave by wave with `harnessly fleet activate` on each, checks them, and puts the machines already moved back with `harnessly fleet rollback` when a wave fails. The machine's own side (stage, activate, rollback, delta, the units spec) is internal/selfupdate; this is the part that used to be a shell script in a deployment's repository. It knows no machine: the list, the way in and the settings of each machine come from the fleet file.

Index

Constants

View Source
const LocalTarget = "local"

LocalTarget is a target that is this machine itself: the command runs here with `sh -c`, no ssh. A fleet whose machine is the one the driver runs on (one pair of a developer's machine, a single-host install) names it so.

Variables

This section is empty.

Functions

func Waves

func Waves(hosts []Host) [][]Host

Waves groups the machines by wave, the lowest first, keeping the file order inside a wave.

Types

type ExecRunner

type ExecRunner struct {
	Cmd    []string
	Stderr io.Writer
}

ExecRunner runs `<Cmd...> <target> <command>` on this machine (ssh, tsh ssh, ...); the target "local" is `sh -c`.

func (ExecRunner) Run

func (r ExecRunner) Run(ctx context.Context, target, command string, stdin io.Reader, stdout io.Writer) error

Run implements Runner. A command that ended with a code comes back as *ExitError.

type ExitError

type ExitError struct{ Code int }

ExitError is a command on a machine that ended with a code.

func (*ExitError) Error

func (e *ExitError) Error() string

type Fleet

type Fleet struct {
	Schema int `json:"schema"`
	// SSH is the command that runs another command on a machine: `<SSH...> <target> <command>`, with stdin passed
	// through. Empty: the caller's default (`ssh`).
	SSH []string `json:"ssh,omitempty"`
	// Transfers is the folder on a machine the tarball is uploaded to.
	Transfers string `json:"transfers,omitempty"`
	// Binary is the harnessly command on a machine (a path or a name on its PATH).
	Binary string `json:"binary,omitempty"`
	Hosts  []Host `json:"hosts"`
}

Fleet is the fleet file (schema 1).

func Load

func Load(path string) (*Fleet, error)

Load reads and checks the fleet file.

func (*Fleet) Select

func (f *Fleet) Select(only []string) ([]Host, error)

Select returns the machines named in only (all of them when only is empty), in file order. A name that is not in the fleet is an error: a typo must not roll nothing out silently.

func (*Fleet) Validate

func (f *Fleet) Validate() error

Validate checks everything that ends up in a command line on a machine.

type Host

type Host struct {
	// Name identifies the machine in `--only` and in the log.
	Name string `json:"name"`
	// Target is the first argument of the ssh command: `root@name`, a Teleport node and so on.
	Target string `json:"target"`
	// Wave orders the rollout: waves go in ascending order, the machines of one wave at the same time. A machine
	// without a wave is in wave 0, the first.
	Wave int `json:"wave,omitempty"`
	// EnvFile is a shell file on the machine with the fleet settings (RUNTIME_FLEET_ROOT, _RESTART, _HEALTH_URL,
	// _SERVICES, _UNITS_SPEC ...). It is sourced before every fleet command.
	EnvFile string `json:"envFile,omitempty"`
	// Root overrides RUNTIME_FLEET_ROOT for this machine (`--root`).
	Root string `json:"root,omitempty"`
	// Binary overrides Fleet.Binary.
	Binary string `json:"binary,omitempty"`
}

Host is one machine.

type Plan

type Plan struct {
	Fleet   *Fleet
	Runner  Runner
	Version string
	// Tarball is the whole release; Delta (with DeltaBase, the commit it was cut against) is optional, see
	// docs/hub/fleet-rollout.md: a machine that runs the base takes the delta, any other gets the whole release.
	Tarball   string
	Delta     string
	DeltaBase string
	Only      []string
	// Force passes --force to activate (the machine's window between rollouts, RUNTIME_FLEET_MIN_GAP).
	Force bool
	// StageJobs caps the machines staged at once (default 4), ActivateJobs those of a wave activated at once
	// (default: the whole wave).
	StageJobs, ActivateJobs int
	StageTimeout            time.Duration // one machine, upload included (default 25 min)
	ActivateTimeout         time.Duration // one machine (default 30 min)
	// Soak is the pause after a wave whose machines all passed, before the next wave starts.
	Soak        time.Duration
	UploadDelay time.Duration // between upload attempts (default 10 s)
	Log         func(format string, a ...any)
	DryRun      bool
	// contains filtered or unexported fields
}

Plan is one rollout.

func (*Plan) Run

func (p *Plan) Run(ctx context.Context) (Result, error)

Run rolls the release out. On a failure the machines that were moved go back with `fleet rollback` (the machine that failed has put itself back already) and the error says which machine and why; Result tells where everything is.

type Result

type Result struct {
	Skipped    []string `json:"skipped,omitempty"`    // already ran the version
	Activated  []string `json:"activated,omitempty"`  // runs the version now
	Failed     []string `json:"failed,omitempty"`     // failed and went back to its own release by itself
	RolledBack []string `json:"rolledBack,omitempty"` // moved, then put back after another machine failed
	NotTouched []string `json:"notTouched,omitempty"` // waves after the failed one
}

Result says what happened to each machine.

type Runner

type Runner interface {
	Run(ctx context.Context, target, command string, stdin io.Reader, stdout io.Writer) error
}

Runner runs a shell command on a machine. stdin and stdout may be nil.

Jump to

Keyboard shortcuts

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