Documentation
¶
Overview ¶
Package lease holds the machine's shared resources, one holder at a time: kind labs, shared installations, the browser. A lease is a directory (mkdir is atomic) holding the holder's record; the record's fields are the ones the lab's earlier shell lock wrote, so both read the same directory.
While a supervisor is recorded, a free lease is not permission: a session claims only what the supervisor granted it, in the order the grants were given, from the supervisor's start to a deliberate stop, whether its session runs or has crashed. Grants live in the state document.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Check ¶
Check decides whether the caller may claim and, when a grant carries the claim, returns its index in st.Grants (-1 when none is needed). While an upgrade runs on the installation of the resource's name only an upgrade-unblock grant admits a claim, in grant order.
Types ¶
type Dir ¶
type Dir string
Dir is the lease directory.
func (Dir) Claim ¶
Claim takes res for h. It returns the current holder instead when res is held already.
type Gate ¶
type Gate struct {
Resource string
Caller state.Party
// Supervisor is the recorded supervisor, nil when none is.
Supervisor *state.Supervisor
// RestartUntil is set while the supervisor's CLI may still come back
// as a restart; Gone once its CLI stayed away longer: claims wait for
// its successor.
RestartUntil time.Time
Gone bool
// Held is whether the resource is held right now (by anyone).
Held bool
Now time.Time
TTL time.Duration
}
Gate is what a claim is checked against.
type Holder ¶
type Holder struct {
// Env is the resource; the field name is the shell lock's.
Env string `json:"env"`
Holder string `json:"holder"`
Session string `json:"session"`
HostSession string `json:"hostSession,omitempty"`
Name string `json:"name,omitempty"`
// Person, Team and Host are the holder party's.
Person string `json:"person,omitempty"`
Team string `json:"team,omitempty"`
Host string `json:"host,omitempty"`
Purpose string `json:"purpose"`
Since string `json:"since"`
// UpgradeUnblock is the reason of the upgrade-unblock grant the claim
// was admitted by during an upgrade, empty for any other claim.
UpgradeUnblock string `json:"upgradeUnblock,omitempty"`
// BudgetGiB is what the holder's models may hold on the model server,
// 0 on every other resource.
BudgetGiB int `json:"budgetGiB,omitempty"`
}
Holder is the record in <leaseDir>/<resource>/holder.json.