submit

package
v0.0.0-...-51f9457 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 9, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package submit contains utilities for Run submission.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComputeOrder

func ComputeOrder(cls []*run.RunCL) ([]*run.RunCL, error)

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

func CurrentRun(ctx context.Context, luciProject string) (common.RunID, error)

CurrentRun returns the RunID that is currently submitting in the submit queue of the provided LUCI Project.

func DeleteQueue

func DeleteQueue(ctx context.Context, luciProject string) error

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

func MustCurrentRun(ctx context.Context, luciProject string) common.RunID

MustCurrentRun is like `CurrentRun(...)` but panic on error.

func Release

func Release(ctx context.Context, notifyFn NotifyFn, runID common.RunID) error

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

  1. 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
  2. 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.

Types

type NotifyFn

type NotifyFn func(ctx context.Context, runID common.RunID, eta time.Time) error

NotifyFn is used to notify the run is ready for submission at `eta`

In production, it is run.Notifier.NotifyReadyForSubmission(...)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL