Documentation
¶
Overview ¶
Package runner provides for execution of Scoot work and retrieval of the results of that work. The core of this is the Runner interface. This package includes a standard runner as well as test and simulation implementations.
Index ¶
- Constants
- func FinalStatus(q StatusQuerier, id RunID) (RunStatus, ServiceStatus, error)
- func SingleStatus(statuses []RunStatus, service ServiceStatus, err error) (RunStatus, ServiceStatus, error)
- func StatusAll(q StatusQueryNower) ([]RunStatus, ServiceStatus, error)
- func StatusNow(q StatusQueryNower, id RunID) (RunStatus, ServiceStatus, error)
- func WaitForState(q StatusQuerier, id RunID, expected RunState) (RunStatus, ServiceStatus, error)
- type Command
- type Controller
- type LegacyStatusReader
- type Output
- type OutputCreator
- type Query
- type RunID
- type RunState
- type RunStatus
- func AbortStatus(runID RunID, tags tags.LogTags) (r RunStatus)
- func CompleteStatus(runID RunID, snapshotID string, exitCode errors.ExitCode, tags tags.LogTags) (r RunStatus)
- func FailedStatus(runID RunID, err *errors.ExitCodeError, tags tags.LogTags) (r RunStatus)
- func PendingStatus(runID RunID, tags tags.LogTags) (r RunStatus)
- func RunningStatus(runID RunID, stdoutRef, stderrRef string, tags tags.LogTags) (r RunStatus)
- func TimeoutStatus(runID RunID, tags tags.LogTags) (r RunStatus)
- type RunType
- type RunTypeMap
- type RunnerID
- type Service
- type ServiceStatus
- type StateMask
- type StatusQuerier
- type StatusQueryNower
- type StatusReader
- type StatusWriter
- type Wait
Constants ¶
const ( UNKNOWN_MASK StateMask = StateMask(1 << uint(PENDING)) PENDING_MASK = 1 << uint(UNKNOWN) RUNNING_MASK = 1 << uint(RUNNING) COMPLETE_MASK = 1 << uint(COMPLETE) FAILED_MASK = 1 << uint(FAILED) ABORTED_MASK = 1 << uint(ABORTED) TIMEDOUT_MASK = 1 << uint(TIMEDOUT) DONE_MASK = (1<<uint(COMPLETE) | 1<<uint(FAILED) | 1<<uint(ABORTED) | 1<<uint(TIMEDOUT) | 1<<uint(UNKNOWN)) ALL_MASK = math.MaxUint64 )
Useful StateMask constants
const LoggingErrMsg = "Error initializing logging."
const NoRunnersMsg = "No runners available."
const RunnerBusyMsg = "Runner is busy"
Variables ¶
This section is empty.
Functions ¶
func FinalStatus ¶
func FinalStatus(q StatusQuerier, id RunID) (RunStatus, ServiceStatus, error)
func SingleStatus ¶
func SingleStatus(statuses []RunStatus, service ServiceStatus, err error) (RunStatus, ServiceStatus, error)
func StatusAll ¶
func StatusAll(q StatusQueryNower) ([]RunStatus, ServiceStatus, error)
StatusAll returns the Current status of all runs
func StatusNow ¶
func StatusNow(q StatusQueryNower, id RunID) (RunStatus, ServiceStatus, error)
Status returns the current status of id from q.
func WaitForState ¶
func WaitForState(q StatusQuerier, id RunID, expected RunState) (RunStatus, ServiceStatus, error)
Types ¶
type Command ¶
type Command struct { // Command line to run Argv []string // Key-value pairs for environment variables EnvVars map[string]string // Kill command after timeout. Zero value is ignored. // Time spent prepping for this command (ex: git checkout) is counted towards the timeout. Timeout time.Duration // Runner can optionally use this to run against a particular snapshot. Empty value is ignored. SnapshotID string // Runner is given JobID, TaskID, and Tag to help trace tasks throughout their lifecycle tags.LogTags // Bazel ExecuteRequest data for tasks initiated from the Bazel API ExecuteRequest *bazelapi.ExecuteRequest }
A command, execution environment, and timeout.
type Controller ¶
type Controller interface { // Run prepares cmd. It returns its status and any errors. // Run may: // enqueue cmd (leading to state PENDING) // run cmd immediately (leading to state RUNNING) // check if cmd is well-formed, and reject it if not (leading to state FAILED) // wait a very short period of time for cmd to start (leading to any state) // Run may not wait indefinitely for cmd to finish. This is an async API. Run(cmd *Command) (RunStatus, error) // Abort kills the given run. Returns its final status (which may not be aborted, // e.g. if it's already completed on its own) Abort(run RunID) (RunStatus, error) // Optional function to clean up process-local resources, ex: cancel goroutines, close connections, etc Release() }
type LegacyStatusReader ¶
type LegacyStatusReader interface { // Status returns the current status of id from q. Status(run RunID) (RunStatus, ServiceStatus, error) // StatusAll returns the Current status of all runs StatusAll() ([]RunStatus, ServiceStatus, error) }
LegacyStatusReader contains legacy methods to read Status'es. Prefer using the convenience methods above.
type Output ¶
type Output interface { // Write (and close) straight to the Output io.WriteCloser // A URI to this Output. Clients can read data by accessing the URI. // This lets us change how we save, because we can write to a local file, // or hdfs, or s3, or any other addressable store. // Returns a resource path prefixed with, for example, "file://" or "hdfs://". URI() string // Copies (if necessary) the URI target to local file and returns that absolute file path. AsFile() string }
Output is a sink for one file's worth of output
type OutputCreator ¶
type OutputCreator interface { // Create an output for the given ID Create(id string) (Output, error) }
OutputCreator lets clients create new Outputs so they can save data. This is how Runner can save stdout and stderr. OutputCreator is the filesystem that creates many Outputs; Output is one file in that. (NB: Saver is temporary until we save output into a new Snapshot)
type Query ¶
type Query struct { Runs []RunID // Runs to query for AllRuns bool // Whether to match all runs States StateMask // What States to match }
Query describes a query for RunStatuses. The Runs and States are and'ed: a RunStatus matches a Query if its ID is in q.Runs (or q.AllRuns) and its state is in q.States
type RunState ¶
type RunState int
const ( // Catch-all for indeterminate RunStates. Also an "end state" UNKNOWN RunState = iota // Waiting to run PENDING // Running RUNNING // Succeeded or failed yielding an exit code COMPLETE // Run mechanism failed and is no longer running FAILED // User requested that the run be killed, or task preempted by Scheduler ABORTED // Run timed out and was killed TIMEDOUT )
type RunStatus ¶
type RunStatus struct { RunID RunID State RunState tags.LogTags // References to stdout and stderr, not their text // Runner impls might not provide valid refs for all States (e.g. failure before creation of refs) StdoutRef string StderrRef string // Only valid if State == COMPLETE SnapshotID string // Only valid if State == (COMPLETE || FAILED) ExitCode errors.ExitCode // Only valid if State == (COMPLETE || FAILED || ABORTED) Error string // Only valid if task is run on a Bazel filer ActionResult *bazelapi.ActionResult }
Returned by the coordinator when a run request is made.
func CompleteStatus ¶
func FailedStatus ¶
func RunningStatus ¶
type RunType ¶
type RunType string
RunTypes distinguish execution behavior for Commands. Used only by the Runner and evaluated using SnapshotIDs.
type RunTypeMap ¶
type RunTypeMap map[RunType]snapshot.FilerAndInitDoneCh
func MakeRunTypeMap ¶
func MakeRunTypeMap() RunTypeMap
type RunnerID ¶
type RunnerID struct {
ID string
}
Can be used to initialize a Runner with specific identifying information
type Service ¶
type Service interface { Controller StatusReader }
Service allows starting/abort'ing runs and checking on their status.
type ServiceStatus ¶
This is for overall runner status, just 'initialized' status and error for now.
func (ServiceStatus) String ¶
func (s ServiceStatus) String() string
type StateMask ¶
type StateMask uint64
StateMask describes a set of States as a bitmask.
func MaskForState ¶
Helper Function to create StateMask that matches exactly state
type StatusQuerier ¶
type StatusQuerier interface { // Query returns all RunStatus'es matching q, waiting as described by w Query(q Query, w Wait) ([]RunStatus, ServiceStatus, error) StatusQueryNower }
StatusQuerier allows reading Status by Query'ing.
type StatusQueryNower ¶
type StatusQueryNower interface { // QueryNow returns all RunStatus'es matching q in their current state QueryNow(q Query) ([]RunStatus, ServiceStatus, error) }
StatusQueryNower allows Query'ing Statuses but with no Waiting This is separate from StatusQuerier because talking to the Worker, e.g., we will be able to QueryNow easily, but because Thrift doesn't like long waits on RPCs, it can't do Query with a decent wait. We want our type system to help protect us from this blowing up at runtime, so the RPC client will implement StatusQueryNower. We will implement a PollingQueuer that wraps a StatusQueryNower and satisfies StatusQuerier.
type StatusReader ¶
type StatusReader interface { StatusQuerier // TODO(dbentley): remove LegacyStatusReader }
StatusReader includes both the preferred and the legacy api.
type StatusWriter ¶
type StatusWriter interface { // NewRun creates a new RunID in state PENDING NewRun() (RunStatus, error) // Update overall service status. UpdateService(st ServiceStatus) error // Update writes a new status. Update(st RunStatus) error }
StatusWriter allows writing Statuses
type Wait ¶
type Wait struct { // How long to wait for Statuses Timeout time.Duration AbortCh chan interface{} }
Wait describes how to Wait. It differs from StatusQuery because StatusQuery describes what RunStatus'es to match, but Timeout of zero means return immediately, no blocking.
func WaitForever ¶
func WaitForever() Wait