linuxhost

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: Apache-2.0 Imports: 18 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 linuxhost runs Linux runners on separate machines. The daemon keeps the scale sets and the scheduler; a remote host only runs the Docker backend, driven one operation at a time by "runner-warden agent" over SSH. Hosts join a hostpool.Pool.

Index

Constants

View Source
const (
	OpPing    = "ping"
	OpPrepare = "prepare"
	OpStart   = "start"
	OpStats   = "stats"
	OpStop    = "stop"
	OpCleanup = "cleanup"
	OpList    = "list"
	OpAdopt   = "adopt"
	OpCaches  = "caches" // measure the automatic caches, trim them to CacheMax
)

Operations an agent serves.

Variables

This section is empty.

Functions

This section is empty.

Types

type AgentBackend

type AgentBackend interface {
	core.Backend
	EnsureImage(ctx context.Context, ref string) error
	Adopt(ctx context.Context, h core.Handle) error
}

AgentBackend is what an agent drives on its host (the Docker backend).

type AgentConfig

type AgentConfig struct {
	Instance        string            `json:"instance"`
	Prefix          string            `json:"prefix"`
	HostID          string            `json:"host_id"`
	Image           string            `json:"image"`
	RunnerUID       int               `json:"runner_uid,omitempty"`
	TmpfsSize       int64             `json:"tmpfs_size,omitempty"`
	OOMScoreAdj     int               `json:"oom_score_adj,omitempty"`
	AllowedBinds    []string          `json:"allowed_binds,omitempty"`
	PersistentNames []string          `json:"persistent_names,omitempty"`
	Caches          []config.Cache    `json:"caches,omitempty"`
	Builds          map[string]string `json:"builds,omitempty"` // image tag -> Dockerfile, built on demand
	LogLevel        string            `json:"log_level,omitempty"`
}

AgentConfig is the part of the daemon's Linux configuration a remote host runs with. Paths that are the host's own (state, sockets, binary) are not sent: the agent derives them from Instance.

type Commander

type Commander interface {
	Command(ctx context.Context, cmd, stdin string) (stdout, stderr string, exit int, err error)
}

Commander runs a command line on the host with stdin (an SSH session).

type Host

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

Host drives one remote host. It is up once it answered a ping with this daemon's version and prepared its Docker backend.

func NewHost

func NewHost(cfg HostConfig) *Host

NewHost builds a Host; it starts down until Probe succeeds.

func (*Host) Adopt

func (h *Host) Adopt(ctx context.Context, hd core.Handle) error

Adopt re-checks an adopted runner's Docker proxy.

func (*Host) Caps

func (h *Host) Caps() core.Caps

Caps implements core.Backend.

func (*Host) Cleanup

func (h *Host) Cleanup(ctx context.Context, runner string) error

Cleanup implements core.Backend.

func (*Host) List

func (h *Host) List(ctx context.Context) ([]core.Handle, error)

List implements core.Backend.

func (*Host) Name

func (h *Host) Name() string

Name is the host's configured name.

func (*Host) Prepare

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

Prepare implements core.Backend.

func (*Host) Probe

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

Probe checks the host, installs this binary when the agent is missing or another version, and prepares the Docker backend. It sets Up.

func (*Host) Start

func (h *Host) Start(ctx context.Context, spec core.RunnerSpec) (core.Handle, error)

Start implements core.Backend. The JIT config travels on stdin.

func (*Host) Stats

func (h *Host) Stats(ctx context.Context, hd core.Handle) (core.Usage, error)

Stats implements core.Backend.

func (*Host) Stop

func (h *Host) Stop(ctx context.Context, hd core.Handle, grace time.Duration) error

Stop implements core.Backend.

func (*Host) TrimCaches added in v0.10.0

func (h *Host) TrimCaches(ctx context.Context, limit int64, inUse []string) ([]autocache.Usage, []autocache.Usage, error)

TrimCaches measures the host's automatic caches and removes the least recently used scopes not in inUse past limit. It returns what is kept and what was removed.

func (*Host) Up

func (h *Host) Up() bool

Up reports the last probe's verdict. It never blocks.

type HostConfig

type HostConfig struct {
	Name    string
	Exec    string // runs the rest of the command as root on the Linux side
	Binary  string // runner-warden on the host
	Cmd     Commander
	Agent   AgentConfig
	Version string // this daemon's version; the host's agent must match
	Self    string // this binary, installed on the host when it differs
	Log     *slog.Logger
}

HostConfig describes one remote host.

type Request

type Request struct {
	Op     string           `json:"op"`
	Config AgentConfig      `json:"config"`
	Spec   *core.RunnerSpec `json:"spec,omitempty"`
	Handle *core.Handle     `json:"handle,omitempty"`
	Runner string           `json:"runner,omitempty"`
	Grace  time.Duration    `json:"grace,omitempty"`
	// OpCaches: the budget and the scopes in use on the host.
	CacheMax   int64    `json:"cache_max,omitempty"`
	CacheInUse []string `json:"cache_in_use,omitempty"`
}

Request is one agent call, sent as JSON on stdin.

type Response

type Response struct {
	Version string            `json:"version"`
	Arch    string            `json:"arch,omitempty"`
	Handle  core.Handle       `json:"handle,omitzero"`
	Handles []core.Handle     `json:"handles,omitempty"`
	Usage   core.Usage        `json:"usage,omitzero"`
	Caches  []autocache.Usage `json:"caches,omitempty"` // kept, most recent first
	Removed []autocache.Usage `json:"removed,omitempty"`
	Error   string            `json:"error,omitempty"`
}

Response is the agent's answer, written as JSON on stdout.

func Dispatch

func Dispatch(ctx context.Context, b AgentBackend, req Request, version string) Response

Dispatch runs one request against b. Failures are reported in the response, never as a crash, so the daemon can tell them from SSH errors.

Jump to

Keyboard shortcuts

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