taskrunner

package
v0.26.0 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2021 License: Apache-2.0 Imports: 19 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewTaskRunner

func NewTaskRunner() *taskRunner

NewTaskRunner returns a new taskRunner. It can process taskqueues that does not contain any wait tasks. TODO: Do we need this abstraction layer now that baseRunner doesn't need a collector?

func NewTaskStatusRunner

func NewTaskStatusRunner(identifiers object.ObjMetadataSet, statusPoller poller.Poller, cache cache.ResourceCache) *taskStatusRunner

NewTaskStatusRunner returns a new TaskStatusRunner.

Types

type Condition added in v0.10.0

type Condition string

Condition is a type that defines the types of conditions which a WaitTask can use.

const (
	// AllCurrent Condition means all the provided resources
	// has reached (and remains in) the Current status.
	AllCurrent Condition = "AllCurrent"

	// AllNotFound Condition means all the provided resources
	// has reached the NotFound status, i.e. they are all deleted
	// from the cluster.
	AllNotFound Condition = "AllNotFound"
)

func (Condition) Meets added in v0.10.0

func (c Condition) Meets(s status.Status) bool

Meets returns true if the provided status meets the condition and false if it does not.

type Options added in v0.7.0

type Options struct {
	PollInterval     time.Duration
	UseCache         bool
	EmitStatusEvents bool
}

Options defines properties that is passed along to the statusPoller.

type Task

type Task interface {
	Name() string
	Action() event.ResourceAction
	Identifiers() object.ObjMetadataSet
	Start(taskContext *TaskContext)
	ClearTimeout()
}

Task is the interface that must be implemented by all tasks that will be executed by the taskrunner.

type TaskContext added in v0.7.0

type TaskContext struct {
	// contains filtered or unexported fields
}

TaskContext defines a context that is passed between all the tasks that is in a taskqueue.

func NewTaskContext added in v0.7.0

func NewTaskContext(eventChannel chan event.Event, resourceCache cache.ResourceCache) *TaskContext

NewTaskContext returns a new TaskContext

func (*TaskContext) AppliedGeneration added in v0.26.0

func (tc *TaskContext) AppliedGeneration(id object.ObjMetadata) (int64, bool)

AppliedGeneration looks up the generation of the given resource after it was applied.

func (*TaskContext) AppliedResourceUIDs added in v0.26.0

func (tc *TaskContext) AppliedResourceUIDs() sets.String

AppliedResourceUIDs returns a set with the UIDs of all the successfully applied resources.

func (*TaskContext) AppliedResources added in v0.23.0

func (tc *TaskContext) AppliedResources() object.ObjMetadataSet

AppliedResources returns all the objects (as ObjMetadata) that were added as applied resources to the TaskContext.

func (*TaskContext) CapturePruneFailure added in v0.26.0

func (tc *TaskContext) CapturePruneFailure(id object.ObjMetadata)

func (*TaskContext) CaptureResourceFailure added in v0.22.4

func (tc *TaskContext) CaptureResourceFailure(id object.ObjMetadata)

func (*TaskContext) EventChannel added in v0.7.0

func (tc *TaskContext) EventChannel() chan event.Event

func (*TaskContext) PruneFailed added in v0.26.0

func (tc *TaskContext) PruneFailed(id object.ObjMetadata) bool

PruneFailed returns true if the passed object identifier has been stored as a prune failure; false otherwise.

func (*TaskContext) PruneFailures added in v0.26.0

func (tc *TaskContext) PruneFailures() object.ObjMetadataSet

func (*TaskContext) ResourceApplied added in v0.8.0

func (tc *TaskContext) ResourceApplied(id object.ObjMetadata, uid types.UID, gen int64)

ResourceApplied updates the context with information about the resource identified by the provided id. Currently, we keep information about the generation of the resource after the apply operation completed.

func (*TaskContext) ResourceCache added in v0.26.0

func (tc *TaskContext) ResourceCache() cache.ResourceCache

func (*TaskContext) ResourceFailed added in v0.22.4

func (tc *TaskContext) ResourceFailed(id object.ObjMetadata) bool

func (*TaskContext) ResourceFailures added in v0.26.0

func (tc *TaskContext) ResourceFailures() object.ObjMetadataSet

func (*TaskContext) ResourceUID added in v0.20.3

func (tc *TaskContext) ResourceUID(id object.ObjMetadata) (types.UID, bool)

ResourceUID looks up the UID of the given resource

func (*TaskContext) TaskChannel added in v0.7.0

func (tc *TaskContext) TaskChannel() chan TaskResult

type TaskResult

type TaskResult struct {
	Err error
}

TaskResult is the type returned from tasks once they have completed or failed. If it has failed or timed out, the Err property will be set.

type TimedOutResource added in v0.19.0

type TimedOutResource struct {
	Identifier object.ObjMetadata

	Status status.Status

	Message string
}

type TimeoutError added in v0.10.0

type TimeoutError struct {
	// Identifiers contains the identifiers of all resources that the
	// WaitTask was waiting for.
	Identifiers object.ObjMetadataSet

	// Timeout is the amount of time it took before it timed out.
	Timeout time.Duration

	// Condition defines the criteria for which the task was waiting.
	Condition Condition

	TimedOutResources []TimedOutResource
}

TimeoutError is a special error used by tasks when they have timed out.

func IsTimeoutError

func IsTimeoutError(err error) (*TimeoutError, bool)

IsTimeoutError checks whether a given error is a TimeoutError.

func (TimeoutError) Error added in v0.10.0

func (te TimeoutError) Error() string

type WaitTask

type WaitTask struct {

	// Ids is the list of resources that we are waiting for.
	Ids object.ObjMetadataSet
	// Condition defines the status we want all resources to reach
	Condition Condition
	// Timeout defines how long we are willing to wait for the condition
	// to be met.
	Timeout time.Duration
	// contains filtered or unexported fields
}

WaitTask is an implementation of the Task interface that is used to wait for a set of resources (identified by a slice of ObjMetadata) will all meet the condition specified. It also specifies a timeout for how long we are willing to wait for this to happen. Unlike other implementations of the Task interface, the wait task is handled in a special way to the taskrunner and is a part of the core package.

func NewWaitTask

func NewWaitTask(name string, ids object.ObjMetadataSet, cond Condition, timeout time.Duration, mapper meta.RESTMapper) *WaitTask

NewWaitTask creates a new wait task where we will wait until the resources specifies by ids all meet the specified condition.

func (*WaitTask) Action added in v0.26.0

func (w *WaitTask) Action() event.ResourceAction

func (*WaitTask) ClearTimeout

func (w *WaitTask) ClearTimeout()

ClearTimeout cancels the timeout for the wait task.

func (*WaitTask) Identifiers

func (w *WaitTask) Identifiers() object.ObjMetadataSet

func (*WaitTask) Name added in v0.26.0

func (w *WaitTask) Name() string

func (*WaitTask) Start

func (w *WaitTask) Start(taskContext *TaskContext)

Start kicks off the task. For the wait task, this just means setting up the timeout timer.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳