Documentation
¶
Overview ¶
Package jobcontrol cancels, suspends, and resumes a project's running jobs.
It finds the running run through the project's run lock, resolves job and attempt selections against it, and signals each job through the executor that owns it. It refuses to signal local processes from a host other than the one that started them. It should not decide run planning or finalization; a cancelled run finalizes through the normal run path.
Index ¶
- Constants
- Variables
- type Controller
- func (controller Controller) Cancel(baseDir, project, runID string, jobIDs []string, wait bool) (string, error)
- func (controller Controller) CancelJobs(runDir, project, runID string, jobIDs []string) (string, error)
- func (controller Controller) Control(baseDir, project, runID string, jobIDs []string, operation string) (string, error)
- func (controller Controller) Select(baseDir, project, runID string, selection Selection, now time.Time) (string, []string, error)
- type Selection
Constants ¶
const ( StateRunning = "running" StatePending = "pending" )
Job states that Selection.States names.
Variables ¶
var States = map[string][]string{ "cancel": {StateRunning, StatePending}, "suspend": {StateRunning}, "resume": {StateRunning}, }
States are the job states each operation acts on: cancel reaches pending jobs too, and suspend and resume only running ones.
Functions ¶
This section is empty.
Types ¶
type Controller ¶
Controller signals jobs through a registry of executors.
func (Controller) Cancel ¶
func (controller Controller) Cancel(baseDir, project, runID string, jobIDs []string, wait bool) (string, error)
Cancel cancels the selected running jobs of project in baseDir, or its whole run when jobIDs is empty. A non-empty runID must be the project's active run, and an array job's ID selects its unfinished tasks. A whole-run cancel marks the queue as cancelling and cancels each unfinished job directly, whichever process calls it. With wait, it returns once the run lock is released.
func (Controller) CancelJobs ¶
func (controller Controller) CancelJobs(runDir, project, runID string, jobIDs []string) (string, error)
CancelJobs cancels jobIDs in runDir through their owning executors. A job that was never submitted is marked cancelled so the run skips it.
func (Controller) Control ¶
func (controller Controller) Control(baseDir, project, runID string, jobIDs []string, operation string) (string, error)
Control suspends or resumes, as named by operation, the selected running jobs of project in baseDir, or every running job when jobIDs is empty. A non-empty runID must be the project's active run. Attempt IDs must name the latest attempt of a running job, and an array job's ID selects its running tasks.
func (Controller) Select ¶
func (controller Controller) Select(baseDir, project, runID string, selection Selection, now time.Time) (string, []string, error)
Select resolves project's active run, which must be runID when runID is not empty, and returns its ID and the sorted IDs of its unfinished jobs, array tasks one by one, that selection chooses. Durations of running jobs end at now. It fails when a name matches no job of the run or no job matches.
type Selection ¶
type Selection struct {
Names []string
Scope model.CommandSelector
Filter jobfilter.Filter
States []string
}
Selection chooses unfinished jobs of a run by job name or by filters. Names select jobs whose name, or whose command's name, is one of them. Scope, Filter, and States narrow further; a job is running once its executor owns it and pending before, and empty States allow both.