Documentation
¶
Overview ¶
Package agent runs the long-poll loop on the runner host. In model B it owns the GitHub relationship: it polls GitHub with the customer's App key, reports its queue metadata to the keyless control plane, and — once the control plane picks a job — mints the JIT config itself and drives the Driver to provision.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Agent ¶
type Agent struct {
Name string
Labels []string
Driver driver.Driver
Client *api.Client
// MinFreeDisk is the free-space floor on the driver's image store, in bytes.
// Under it the agent deselects itself — it keeps polling but reports no free
// capacity, so the work stays schedulable on a host that can actually run it
// instead of failing here. Zero disables the gate, as does a driver that
// can't locate its store.
MinFreeDisk uint64
// ReclaimFloor is the free-space mark reclaim works to keep clear. It is
// separate from MinFreeDisk so that disabling the gate leaves upkeep
// running: an operator who never wants work refused still wants the caches
// collected. Zero disables reclaim.
ReclaimFloor uint64
// contains filtered or unexported fields
}
Agent runs the dispatch loop and tracks busy slots.
func New ¶
func New(name string, labels []string, drv driver.Driver, client *api.Client, minter Minter, orgPriority map[string]int, jobs <-chan domain.Job) *Agent
New constructs an Agent. minter mints JIT configs with the customer's App key; jobs is the stream of pending jobs from the GitHub source; orgPriority is the advisory per-org priority reported to the control plane.
func (*Agent) ReconcileOrphans ¶
ReconcileOrphans destroys slots the Driver still owns that this agent isn't accounting for: what a previous process lifetime left behind (launchd SIGKILL/OOM), and what a Destroy that failed mid-dispatch stranded. Called at startup before Run, and on reconcileInterval thereafter.
The listing is read before the busy set, and never the other way around: a slot that goes busy in between was created after the listing, so it can't be in it. Reversing that would let a runner provisioned mid-sweep look like an orphan and be destroyed under its job.
Driver.List filters by NamePrefix, so unrelated user VMs are safe. Running two ushr-agent instances on the same host with the default prefix would reap each other's VMs — single-agent assumption holds for v0.1.
type DispatchObserver ¶
DispatchObserver is implemented by sources that keep a per-dispatch supply ledger (scale sets): every terminal report clears the runner's entry immediately, so supply reconciliation runs on real events rather than TTL backstops. Handles the source never minted are a no-op.
type Minter ¶
type Minter interface {
Mint(ctx context.Context, name string, job domain.Job, labels []string) (string, error)
}
Minter mints a single-use JIT runner config with the customer's own App key. *jit.Minter is the production implementation; the scaleset Source is the other (it registers the runner into its scale set at mint time).