Documentation
¶
Overview ¶
Package docker implements the Driver interface by running each ephemeral runner as a container via the Docker or Podman CLI (autodetected, or pinned via Options.Runtime — the two are drop-in for the subcommands used here). It is deliberately much thinner than the Tart driver: no VM clone, no boot wait, no SSH. A slot is one `run -d` of the runner image launched with `run.sh --jitconfig`, status is one `inspect`, teardown is one `rm -f`.
Unlike Tart (Apple caps macOS guests at 2 per host), container capacity is bounded only by host CPU/memory, so Capacity is purely config-driven.
Containers carry the label ushr=runner so List() can find ours and reconcile orphans on agent restart without touching unrelated containers on the host.
Index ¶
- Constants
- type Driver
- func (d *Driver) Capacity() int
- func (d *Driver) Destroy(ctx context.Context, h driver.SlotHandle) error
- func (d *Driver) DiskPath(ctx context.Context) string
- func (d *Driver) List(ctx context.Context) ([]driver.SlotHandle, error)
- func (d *Driver) Maintain(ctx context.Context)
- func (d *Driver) Provision(ctx context.Context, req driver.ProvisionRequest) (driver.SlotHandle, error)
- func (d *Driver) ReclaimTiers(ctx context.Context) []driver.Tier
- func (d *Driver) StartedJob(ctx context.Context, h driver.SlotHandle) (bool, error)
- func (d *Driver) Status(ctx context.Context, h driver.SlotHandle) (driver.Status, error)
- type Options
Constants ¶
const ( DefaultEntrypoint = "/home/runner/run.sh" DefaultCapacity = 4 DefaultBuildkitImage = "moby/buildkit:buildx-stable-1" DefaultBuildCacheGB = 20 DefaultBuildCacheIdleHours = 168 // reap a repo's builder after a week idle // DefaultMinFreeGB is the free-space floor under which the agent stops // accepting work. Containers are thin next to a VM clone, but one job's // image pulls and build cache still land in the same data root. DefaultMinFreeGB = 25 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Driver ¶
type Driver struct {
// contains filtered or unexported fields
}
Driver is the Docker implementation of driver.Driver.
func (*Driver) Destroy ¶
Destroy force-removes the container. Treated as success if it is already gone.
func (*Driver) DiskPath ¶
DiskPath resolves the runtime's data root — images, container layers and the build cache all live there. Docker and podman name it differently in `info`, and a daemon that is down at boot must not poison the answer, so only a successful lookup is cached.
func (*Driver) Maintain ¶
Maintain runs the driver's upkeep until ctx is cancelled. It re-pulls the runner image because `run` never refreshes a local tag, and GitHub rejects a runner whose version it has deprecated.
func (*Driver) Provision ¶
func (d *Driver) Provision(ctx context.Context, req driver.ProvisionRequest) (driver.SlotHandle, error)
Provision starts a detached runner container. The JIT config carries the runner name, labels, and registration — the controller already baked those in via GenerateOrgJITConfig, so the driver only has to hand it to run.sh.
func (*Driver) ReclaimTiers ¶
ReclaimTiers frees data-root space. What a job creates through the shared docker socket carries none of our labels, so collecting it means deleting objects we can't prove are idle: those steps are drain-gated, and further gated on the operator declaring the daemon ours alone. Without that declaration reclaim is limited to our own build cache and unreferenced layers, and a shared daemon's disk stays the operator's to manage.
func (*Driver) StartedJob ¶
StartedJob reports whether the runner has begun a job, read from its console log. A gone container counts as not-started (Status reports it Done); the runner's output can land on either stream depending on the image entrypoint, so both are scanned.
type Options ¶
type Options struct {
Image string
Capacity int
Runtime string // "docker" | "podman"; empty autodetects
Network string
Volumes []string
ExtraHosts []string
GroupAdd []string
Memory string
Entrypoint string
// Per-repo persistent build cache (docker driver).
BuildCache bool
BuildkitImage string
BuildCacheGB int
BuildCacheIdleHrs int
StateDir string
// ActionCache is the host action archive cache, mounted read-only.
ActionCache string
// Exclusive declares that no workload other than ushr's runners uses this
// daemon, which is what lets reclaim collect the containers, volumes and
// images jobs leave behind through the shared socket. Off by default: on a
// daemon someone else also uses, those objects are not ours to delete.
Exclusive bool
}
Options configures a Driver. Zero values fall back to Default* constants.