Documentation
¶
Overview ¶
Package placement decides which queued agent task goes to which runner.
Place is a pure function: it takes every input as a value, the clock included, does no I/O, and returns its decisions. Beekeeper runs it whenever an input changes, and Capacity answers a queue's gate with the same rules.
The rules:
- Order: class (incident, repair, continuing, starting), then the task's priority (lower first, unset last), then age (older first).
- Matching: a runner of the task's organization that is connected, whose host may still work, whose purposes take the task's kind, whose focus matches the task's fields, that has the task's required capabilities and a harness for it, that hasn't just declined it, that has a free slot, whose pressure is within bounds, and one of whose subscriptions is on pace for the task's class.
- Affinity: a task prefers its preferred runner, and a continuing task without one the runner of its subject's last session. While that runner is held only by something that passes (a full slot, pressure, pace, a reconnect), the task waits for it up to the affinity wait; then any matching runner takes it.
- Choice: among the runners and subscriptions that fit, preferred capabilities first, then the preferred provider (and the provider to avoid last), then paced subscriptions before unpaced ones, then the subscription furthest behind its pace, then the runner with the most free slots.
- A task that waits gets the reason of the runners that came closest, naming the gate with its numbers, such as `no free slot with docker: laptop-a 2/2`.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultPolicy = Policy{ AffinityWait: 5 * time.Minute, DeclineBackoff: 10 * time.Minute, Limits: Limits{ MaxLoad: 0.9, MinFreeMemory: resource.MustParse("2Gi"), MinFreeDisk: resource.MustParse("10Gi"), MinGitHubRemaining: 500, }, Pace: pace.DefaultRules, }
DefaultPolicy is placement's default configuration.
Functions ¶
This section is empty.
Types ¶
type Answer ¶
type Answer struct {
// Available is true when a runner would take the task now.
Available bool `json:"available"`
// Gate and Reason say, when none would, what holds it.
Gate Gate `json:"gate"`
Reason string `json:"reason"`
// Runner, Harness, Subscription and Provider say where it would go.
Runner string `json:"runner"`
Harness string `json:"harness"`
Subscription string `json:"subscription"`
Provider string `json:"provider"`
}
Answer is whether a runner could take a hypothetical task now.
type Gate ¶
type Gate string
Gate names the check that holds a task. It labels metrics.
const ( GateNoRunner Gate = "no_runner" GateOffline Gate = "offline" GateHost Gate = "host" GatePurpose Gate = "purpose" GateFocus Gate = "focus" GateCapability Gate = "capability" GateHarness Gate = "harness" GateDeclined Gate = "declined" GateSlot Gate = "slot" GatePressure Gate = "pressure" GatePace Gate = "pace" GateAffinity Gate = "affinity" )
The gates, in the order a runner is checked.
type Input ¶
type Input struct {
// Now is the clock.
Now time.Time
// Tasks are the tasks to place and those that hold slots or
// reservations. Only queued ones are placed.
Tasks []v1alpha1.AgentTask
// Runners are the registered runners, with their live status.
Runners []v1alpha1.Runner
// Sessions are recent sessions, for each subject's last runner.
Sessions []v1alpha1.AgentSession
// Subscriptions are the subscriptions with their newest readings.
Subscriptions []v1alpha1.Subscription
}
Input is everything placement decides on.
type Limits ¶
type Limits struct {
MaxLoad float64
MinFreeMemory resource.Quantity
MinFreeDisk resource.Quantity
MinGitHubRemaining int32
}
Limits are the default pressure bounds for runners that set none.
type Offer ¶
type Offer struct {
Namespace string
Task string
Runner string
Harness string
Subscription string
Provider string
// Reservation is the headroom to hold on the subscription, unset for an
// unpaced one.
Reservation *v1alpha1.Reservation
}
Offer places a task on a runner.
type Policy ¶
type Policy struct {
// AffinityWait is how long a task waits for its preferred runner.
AffinityWait time.Duration
// DeclineBackoff is how long a runner that declined a task isn't offered
// it again.
DeclineBackoff time.Duration
// Limits are the default pressure bounds.
Limits Limits
// Pace are the default pace rules.
Pace pace.Rules
}
Policy holds placement's configuration.