Documentation ¶
Overview ¶
Package submit contains utilities for Run submission.
Index ¶
- func ComputeOrder(cls []*run.RunCL) ([]*run.RunCL, error)
- func CurrentRun(ctx context.Context, luciProject string) (common.RunID, error)
- func DeleteQueue(ctx context.Context, luciProject string) error
- func LoadCurrentAndWaitlist(ctx context.Context, runID common.RunID) (current common.RunID, waitlist common.RunIDs, err error)
- func MustCurrentRun(ctx context.Context, luciProject string) common.RunID
- func Release(ctx context.Context, notifyFn NotifyFn, runID common.RunID) error
- func TryAcquire(ctx context.Context, notifyFn NotifyFn, runID common.RunID, ...) (waitlisted bool, err error)
- type NotifyFn
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ComputeOrder ¶
ComputeOrder computes the best order for submission of CLs based on their dependencies. Dependency cycle is broken by arbitrarily but deterministically breaking soft requirement dependencies and approximately minimizing their number.
Returns error if duplicate CLs are provided or the hard requirement dependencies solely form a cycle (This should not be possible within current CV context as hard requirement deps can only be established if CLs follow Git's child -> parent relationship).
Overall, this is as hard as a minimum feedback arc set, which is NP-Hard: https://en.wikipedia.org/wiki/Feedback_arc_set#Minimum_feedback_arc_set However, approximation is fine within CV context so long as hard dependencies are satisfied.
func CurrentRun ¶
CurrentRun returns the RunID that is currently submitting in the submit queue of the provided LUCI Project.
func DeleteQueue ¶
DeleteQueue deletes the submit queue of the provided LUCI Project.
func LoadCurrentAndWaitlist ¶
func LoadCurrentAndWaitlist(ctx context.Context, runID common.RunID) (current common.RunID, waitlist common.RunIDs, err error)
LoadCurrentAndWaitlist loads the current submission slot and the waitlist.
func MustCurrentRun ¶
MustCurrentRun is like `CurrentRun(...)` but panic on error.
func Release ¶
Release releases the slot occupied by the provided Run.
If the provided Run occupies the current slot, give it up and notify the first Run in the waitlist is ready for submission. If the provided Run is in waitlist, remove it from the waitlist. If the provided Run is not present in the submit queue, no-op.
MUST be called in a datastore transaction.
func TryAcquire ¶
func TryAcquire(ctx context.Context, notifyFn NotifyFn, runID common.RunID, opts *cfgpb.SubmitOptions) (waitlisted bool, err error)
TryAcquire tries to acquire the current submission slot from the submit queue.
Succeeds iff both
- queue is empty or the requested Run is the first in the waitlist and no Run is occupying the current submission slot at this moment
- acquisition of the current slot satisfies the rate limit.
Otherwise, this Run will be added to the waitlist and will be notified later after all Runs ahead of it have released their slots and the rate limit allows. Acquiring a slot for an existing Run in the submit queue won't change its position in the queue unless this Run is the first Run in the waitlist and the aforementioned conditions are met.
The caller SHOULD submit the Run only after it successfully acquires the current submission slot. The caller is also RECOMMENDED to submit a task in the same transaction that runs later to check if the submission have failed unexpectedly without releasing the slot so that the submission slot is blocked on this Run.
MUST be called in a datastore transaction.