restask

package
v3.0.0-rc67 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2026 License: Apache-2.0 Imports: 29 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// GroupScheduling holds when the task runs: by its schedule, or on
	// the events of the node, at a pace.
	GroupScheduling = keywords.Group{
		ID:    "scheduling",
		Name:  "Scheduling",
		Text:  keywords.NewText(fs, "text/group/scheduling"),
		Order: 32,
	}

	// GroupRun holds how a run of the task goes: the confirmation it
	// asks, how many run at once, its outputs logged, and the command run
	// when it fails.
	GroupRun = keywords.Group{
		ID:    "run",
		Name:  "Runs",
		Text:  keywords.NewText(fs, "text/group/run"),
		Order: 34,
	}

	// GroupStatus holds how the runs of the task make the status of its
	// resource.
	GroupStatus = keywords.Group{
		ID:    "status",
		Name:  "Status",
		Text:  keywords.NewText(fs, "text/group/status"),
		Order: 36,
	}

	// GroupInstall holds the volumes and filesystems whose files the task
	// installs again before its own work.
	GroupInstall = keywords.Group{
		ID:    "install",
		Name:  "Install",
		Text:  keywords.NewText(fs, "text/group/install"),
		Order: 46,
	}

	// GroupTimeouts holds how long a run of the task may take, and how
	// long its stop waits for the runs to end. It has the id, name and
	// order of the timeouts of the containers.
	GroupTimeouts = keywords.Group{
		ID:    "timeouts",
		Name:  "Timeouts",
		Text:  keywords.NewText(fs, "text/group/timeouts"),
		Order: 90,
	}

	// Groups are the groups the keywords every task driver has name.
	Groups = []keywords.Group{
		GroupScheduling,
		GroupRun,
		GroupStatus,
		GroupInstall,
		GroupTimeouts,
	}
)

The groups of the keywords every task driver has, declared once here and added by each task driver. The drivers add their own groups, as the image of an oci task or the certificates of an acme task, in the order between these.

View Source
var (
	Keywords = []*keywords.Keyword{
		{
			Attr:       "Check",
			Candidates: []string{"last_run", "last_run_warn", ""},
			Example:    "last_run",
			Option:     "check",
			Group:      GroupStatus.ID,
			Scopable:   true,
			Text:       keywords.NewText(fs, "text/kw/check"),
		},
		{
			Attr:      "Confirmation",
			Converter: converters.Bool,
			Option:    "confirmation",
			Group:     GroupRun.ID,
			Text:      keywords.NewText(fs, "text/kw/confirmation"),
		},
		{
			Attr:       "Install",
			Converter:  converters.List,
			Example:    "fs#1",
			Option:     "install",
			Group:      GroupInstall.ID,
			References: &keywords.References{Groups: []string{"fs", "volume"}, Shape: keywords.ReferencesRIDs},
			Scopable:   true,
			Validate:   validInstall,
			Text:       keywords.NewText(fs, "text/kw/install"),
		},
		{
			Attr:      "LogOutputs",
			Converter: converters.Bool,
			Default:   "false",
			Option:    "log",
			Group:     GroupRun.ID,
			Scopable:  true,
			Text:      keywords.NewText(fs, "text/kw/log"),
		},
		{
			Attr:      "MaxParallel",
			Converter: converters.Int,
			Default:   "1",
			Example:   "2",
			Option:    "max_parallel",
			Group:     GroupRun.ID,
			Scopable:  true,
			Text:      keywords.NewText(fs, "text/kw/max_parallel"),
		},
		{
			Attr:      "On",
			Converter: converters.List,
			Example:   "NetworkPeersUpdated,name=backend1",
			Option:    "on",
			Group:     GroupScheduling.ID,
			Scopable:  true,
			Validate:  validOn,
			Text:      keywords.NewText(fs, "text/kw/on"),
		},
		{
			Attr:     "Pace",
			Default:  schedule.DefaultPace,
			Example:  "@30s backoff @1m",
			Option:   "pace",
			Group:    GroupScheduling.ID,
			Scopable: true,
			Validate: validPace,
			Text:     keywords.NewText(fs, "text/kw/pace"),
		},
		{
			Attr:     "OnErrorCmd",
			Example:  "/srv/{name}/data/scripts/task_on_error.sh",
			Option:   "on_error",
			Group:    GroupRun.ID,
			Scopable: true,
			Text:     keywords.NewText(fs, "text/kw/on_error"),
		},
		{
			Attr:     "RetCodes",
			Default:  "0:up 1:down",
			Example:  "0:up 1:down 3:warn 4: n/a 5:undef",
			Option:   "retcodes",
			Group:    GroupStatus.ID,
			Required: false,
			Scopable: true,
			Text:     keywords.NewText(fs, "text/kw/retcodes"),
		},
		{
			Attr:      "RunTimeout",
			Converter: converters.Duration,
			Example:   "1m30s",
			Option:    "run_timeout",
			Group:     GroupTimeouts.ID,
			Scopable:  true,
			Text:      keywords.NewText(fs, "text/kw/run_timeout"),
		},
		{
			Attr:          "Schedule",
			DefaultOption: "run_schedule",
			Example:       "00:00-01:00 mon",
			Option:        "schedule",
			Group:         GroupScheduling.ID,
			Scopable:      true,
			Text:          keywords.NewText(fs, "text/kw/schedule"),
		},
		{
			Attr:      "Snooze",
			Converter: converters.Duration,
			Example:   "10m",
			Option:    "snooze",
			Group:     GroupRun.ID,
			Scopable:  true,
			Text:      keywords.NewText(fs, "text/kw/snooze"),
		},
		{
			Attr:      "Timeout",
			Converter: converters.Duration,
			Example:   "5m",
			Option:    "timeout",
			Group:     GroupTimeouts.ID,
			Scopable:  true,
			Text:      keywords.NewText(fs, "text/kw/timeout"),
		},
	}
)

Functions

This section is empty.

Types

type BaseTask

type BaseTask struct {
	resource.T
	Check        string
	Confirmation bool
	Install      []string
	LogOutputs   bool
	MaxParallel  int
	On           []string
	Pace         string
	OnErrorCmd   string
	RetCodes     string
	RunTimeout   *time.Duration
	Schedule     string
	Snooze       *time.Duration
}

func (*BaseTask) Boot

func (t *BaseTask) Boot(ctx context.Context) error

Boot forgets the last run, as the stop does: the node booted, the instance is not started.

func (*BaseTask) ExitCodeToStatus

func (t *BaseTask) ExitCodeToStatus(exitCode int) (status.T, error)

func (*BaseTask) Provisioned

func (t *BaseTask) Provisioned(ctx context.Context) (provisioned.T, error)

Provisioned returns NotApplicable: a task has nothing to provision.

func (*BaseTask) RunDir

func (t *BaseTask) RunDir() runfiles.Dir

func (*BaseTask) RunIf

func (t *BaseTask) RunIf(ctx context.Context, fn func(context.Context) error) error

func (*BaseTask) RunInstall

func (t *BaseTask) RunInstall(ctx context.Context) error

RunInstall installs again the files of the resources the install keyword names, rendering their templates from what the node knows now, before the task does its own work. The files it changes are recorded, which the daemon tells the tasks on FileInstalled.

A failed install is the failed run of the task.

func (*BaseTask) RunTimeLimit

func (t *BaseTask) RunTimeLimit(timeout *time.Duration) time.Duration

RunTimeLimit returns how long a run may last: run_timeout, which takes precedence, or the timeout of the driver, and zero for no limit.

func (*BaseTask) Running

func (t *BaseTask) Running() (resource.RunningInfoList, error)

func (*BaseTask) ScheduleOptions

func (t *BaseTask) ScheduleOptions() resource.ScheduleOptions

func (*BaseTask) Status

func (t *BaseTask) Status(ctx context.Context) status.T

func (*BaseTask) StatusInfo

func (t *BaseTask) StatusInfo(ctx context.Context) map[string]any

func (*BaseTask) Stop

func (t *BaseTask) Stop(ctx context.Context) error

Stop forgets the last run, as v2 did: the check=last_run status of a task stopped with its instance would keep the outcome of a run, up, while the instance is down. A stop of the task alone, by --rid, forgets it too: it is the stop of the resource.

func (*BaseTask) StopRuns

func (t *BaseTask) StopRuns(ctx context.Context, timeout *time.Duration) error

StopRuns stops the runs of the task: each "om instance run" process is sent SIGTERM, which it relays to the command it runs, or to the container of the run, and those still running after timeout are killed, with the processes they started.

func (*BaseTask) UnprovisionStop

func (t *BaseTask) UnprovisionStop(ctx context.Context, leader bool) error

UnprovisionStop stops the runs of the task, then forgets the last run: an unprovision, as the one of a purge, leaves no run behind, whose end would write its result in a var dir deleted, or in the one of an object recreated under the name. A stop leaves the runs alone, as in v2.

func (*BaseTask) WriteLastRun

func (t *BaseTask) WriteLastRun(retcode int) error

type LastRun

type LastRun struct {
	At        time.Time `json:"at"`
	ExitCode  int       `json:"exitcode"`
	SessionID uuid.UUID `json:"session_id"`

	// ObjectID is the id of the object whose run this is: a run
	// ending after its object was deleted writes in the var dir of
	// the object recreated under the name, which this tells apart.
	ObjectID uuid.UUID `json:"object_id,omitempty"`
}

Jump to

Keyboard shortcuts

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