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
- type AgentBackend
- type AgentConfig
- type Commander
- type Host
- func (h *Host) Adopt(ctx context.Context, hd core.Handle) error
- func (h *Host) Caps() core.Caps
- func (h *Host) Cleanup(ctx context.Context, runner string) error
- func (h *Host) List(ctx context.Context) ([]core.Handle, error)
- func (h *Host) Name() string
- func (h *Host) Prepare(ctx context.Context) error
- func (h *Host) Probe(ctx context.Context) error
- func (h *Host) Start(ctx context.Context, spec core.RunnerSpec) (core.Handle, error)
- func (h *Host) Stats(ctx context.Context, hd core.Handle) (core.Usage, error)
- func (h *Host) Stop(ctx context.Context, hd core.Handle, grace time.Duration) error
- func (h *Host) TrimCaches(ctx context.Context, limit int64, inUse []string) ([]autocache.Usage, []autocache.Usage, error)
- func (h *Host) Up() bool
- type HostConfig
- type Request
- type Response
Constants ¶
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) Probe ¶
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) 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.
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.