engine

package
v1.45.0 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2020 License: Apache-2.0 Imports: 42 Imported by: 365

Documentation

Overview

Package engine contains code for interacting with container-running backends and handling events from them. It supports Docker as the sole task engine type.

Package engine contains the core logic for managing tasks

Index

Constants

View Source
const (
	//DockerEndpointEnvVariable is the environment variable that can override the Docker endpoint
	DockerEndpointEnvVariable = "DOCKER_HOST"
	// DockerDefaultEndpoint is the default value for the Docker endpoint
	DockerDefaultEndpoint = "unix:///var/run/docker.sock"

	FluentNetworkPortValue = "24224"
	FluentAWSVPCHostValue  = "127.0.0.1"
)

Variables

View Source
var ImagePullDeleteLock sync.RWMutex

ImagePullDeleteLock ensures that pulls and deletes do not run at the same time and pulls can be run at the same time for docker >= 1.11.1 Pulls are serialized as a temporary workaround for a devicemapper issue. (see https://github.com/docker/docker/issues/9718) Deletes must not run at the same time as pulls to prevent deletion of images that are being used to launch new tasks.

Functions

This section is empty.

Types

type CannotGetDockerClientVersionError added in v1.16.0

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

CannotGetDockerClientVersionError indicates error when trying to get docker client api version

func (CannotGetDockerClientVersionError) Error added in v1.16.0

func (CannotGetDockerClientVersionError) ErrorName added in v1.16.0

func (err CannotGetDockerClientVersionError) ErrorName() string

type ContainerNetworkingError added in v1.14.5

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

ContainerNetworkingError indicates any error when dealing with the network namespace of container

func (ContainerNetworkingError) Error added in v1.14.5

func (err ContainerNetworkingError) Error() string

func (ContainerNetworkingError) ErrorName added in v1.14.5

func (err ContainerNetworkingError) ErrorName() string

type ContainerVanishedError added in v1.1.0

type ContainerVanishedError struct{}

ContainerVanishedError is a type for describing a container that does not exist

func (ContainerVanishedError) Error added in v1.1.0

func (err ContainerVanishedError) Error() string

func (ContainerVanishedError) ErrorName added in v1.1.0

func (err ContainerVanishedError) ErrorName() string

ErrorName returns the name of the error

type DockerTaskEngine

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

DockerTaskEngine is a state machine for managing a task and its containers in ECS.

DockerTaskEngine implements an abstraction over the DockerGoClient so that it does not have to know about tasks, only containers The DockerTaskEngine interacts with Docker to implement a TaskEngine

func NewDockerTaskEngine

func NewDockerTaskEngine(cfg *config.Config,
	client dockerapi.DockerClient,
	credentialsManager credentials.Manager,
	containerChangeEventStream *eventstream.EventStream,
	imageManager ImageManager,
	state dockerstate.TaskEngineState,
	metadataManager containermetadata.Manager,
	resourceFields *taskresource.ResourceFields) *DockerTaskEngine

NewDockerTaskEngine returns a created, but uninitialized, DockerTaskEngine. The distinction between created and initialized is that when created it may be serialized/deserialized, but it will not communicate with docker until it is also initialized.

func (*DockerTaskEngine) AddTask

func (engine *DockerTaskEngine) AddTask(task *apitask.Task)

AddTask starts tracking a task

func (*DockerTaskEngine) Disable added in v1.0.0

func (engine *DockerTaskEngine) Disable()

Disable prevents this engine from managing any additional tasks.

func (*DockerTaskEngine) GetTaskByArn added in v1.8.2

func (engine *DockerTaskEngine) GetTaskByArn(arn string) (*apitask.Task, bool)

GetTaskByArn returns the task identified by that ARN

func (*DockerTaskEngine) Init

func (engine *DockerTaskEngine) Init(ctx context.Context) error

Init initializes a DockerTaskEngine such that it may communicate with docker and operate normally. This function must be called before any other function, except serializing and deserializing, can succeed without error.

func (*DockerTaskEngine) ListTasks

func (engine *DockerTaskEngine) ListTasks() ([]*apitask.Task, error)

ListTasks returns the tasks currently managed by the DockerTaskEngine

func (*DockerTaskEngine) LoadState added in v1.44.0

func (engine *DockerTaskEngine) LoadState() error

LoadState populates the task engine state with data in db.

func (*DockerTaskEngine) MarshalJSON

func (engine *DockerTaskEngine) MarshalJSON() ([]byte, error)

MarshalJSON marshals into state directly

func (*DockerTaskEngine) MustInit

func (engine *DockerTaskEngine) MustInit(ctx context.Context)

MustInit blocks and retries until an engine can be initialized.

func (*DockerTaskEngine) SaveState added in v1.44.0

func (engine *DockerTaskEngine) SaveState() error

SaveState saves all the data in task engine state to db.

func (*DockerTaskEngine) SetDataClient added in v1.44.0

func (engine *DockerTaskEngine) SetDataClient(client data.Client)

SetDataClient sets the saver that is used by the DockerTaskEngine.

func (*DockerTaskEngine) Shutdown added in v1.1.0

func (engine *DockerTaskEngine) Shutdown()

Shutdown makes a best-effort attempt to cleanup after the task engine. This should not be relied on for anything more complicated than testing.

func (*DockerTaskEngine) State

State is a function primarily meant for testing usage; it is explicitly not part of the TaskEngine interface and should not be relied upon. It returns an internal representation of the state of this DockerTaskEngine.

func (*DockerTaskEngine) StateChangeEvents added in v1.14.2

func (engine *DockerTaskEngine) StateChangeEvents() chan statechange.Event

StateChangeEvents returns channels to read task and container state changes. These changes should be read as soon as possible as them not being read will block processing the task referenced by the event.

func (*DockerTaskEngine) UnmarshalJSON

func (engine *DockerTaskEngine) UnmarshalJSON(data []byte) error

UnmarshalJSON restores a previously marshaled task-engine state from json

func (*DockerTaskEngine) Version added in v1.0.0

func (engine *DockerTaskEngine) Version() (string, error)

Version returns the underlying docker version.

type ImageManager added in v1.13.0

type ImageManager interface {
	RecordContainerReference(container *apicontainer.Container) error
	RemoveContainerReferenceFromImageState(container *apicontainer.Container) error
	AddAllImageStates(imageStates []*image.ImageState)
	GetImageStateFromImageName(containerImageName string) (*image.ImageState, bool)
	StartImageCleanupProcess(ctx context.Context)
	SetDataClient(dataClient data.Client)
}

ImageManager is responsible for saving the Image states, adding and removing container references to ImageStates

func NewImageManager added in v1.13.0

func NewImageManager(cfg *config.Config, client dockerapi.DockerClient, state dockerstate.TaskEngineState) ImageManager

NewImageManager returns a new ImageManager

type ImageStatesForDeletion added in v1.13.0

type ImageStatesForDeletion []*image.ImageState

ImageStatesForDeletion is used for implementing the sort interface

func (ImageStatesForDeletion) Len added in v1.13.0

func (imageStates ImageStatesForDeletion) Len() int

Implementing sort interface based on last used times of the images

func (ImageStatesForDeletion) Less added in v1.13.0

func (imageStates ImageStatesForDeletion) Less(i, j int) bool

func (ImageStatesForDeletion) Swap added in v1.13.0

func (imageStates ImageStatesForDeletion) Swap(i, j int)

type ImageWithSizeID added in v1.28.1

type ImageWithSizeID struct {
	RepoTags []string
	ImageID  string
	Size     int64
	// contains filtered or unexported fields
}

type TaskDependencyError added in v1.14.2

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

TaskDependencyError is the error for task that dependencies can't be resolved

func (TaskDependencyError) Error added in v1.14.2

func (err TaskDependencyError) Error() string

func (TaskDependencyError) ErrorName added in v1.14.2

func (err TaskDependencyError) ErrorName() string

ErrorName is the name of the error

type TaskEngine

type TaskEngine interface {
	Init(context.Context) error
	MustInit(context.Context)
	// Disable *must* only be called when this engine will no longer be used
	// (e.g. right before exiting down the process). It will irreversibly stop
	// this task engine from processing new tasks
	Disable()

	// StateChangeEvents will provide information about tasks that have been previously
	// executed. Specifically, it will provide information when they reach
	// running or stopped, as well as providing portbinding and other metadata
	StateChangeEvents() chan statechange.Event
	// SetDataClient sets the data client that is used by the task engine.
	SetDataClient(data.Client)

	// AddTask adds a new task to the task engine and manages its container's
	// lifecycle. If it returns an error, the task was not added.
	AddTask(*apitask.Task)

	// ListTasks lists all the tasks being managed by the TaskEngine.
	ListTasks() ([]*apitask.Task, error)

	// GetTaskByArn gets a managed task, given a task arn.
	GetTaskByArn(string) (*apitask.Task, bool)

	Version() (string, error)

	// LoadState loads the task engine state with data in db.
	LoadState() error
	// SaveState saves all the data in task engine state to db.
	SaveState() error

	json.Marshaler
	json.Unmarshaler
}

TaskEngine is an interface for the DockerTaskEngine

func NewTaskEngine

func NewTaskEngine(cfg *config.Config, client dockerapi.DockerClient,
	credentialsManager credentials.Manager,
	containerChangeEventStream *eventstream.EventStream,
	imageManager ImageManager, state dockerstate.TaskEngineState,
	metadataManager containermetadata.Manager,
	resourceFields *taskresource.ResourceFields) TaskEngine

NewTaskEngine returns a default TaskEngine

type TaskStoppedBeforePullBeginError added in v1.13.0

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

TaskStoppedBeforePullBeginError is a type for task errors involving pull

func (TaskStoppedBeforePullBeginError) Error added in v1.13.0

func (TaskStoppedBeforePullBeginError) ErrorName added in v1.13.0

ErrorName returns the name of the error

Directories

Path Synopsis
mocks
Package mock_dockerstate is a generated GoMock package.
Package mock_dockerstate is a generated GoMock package.
testutils
Package testutils contains files that are used in tests but not elsewhere and thus can be excluded from the final executable.
Package testutils contains files that are used in tests but not elsewhere and thus can be excluded from the final executable.
Package mock_engine is a generated GoMock package.
Package mock_engine is a generated GoMock package.
Package testutils contains files that are used in tests but not elsewhere and thus can be excluded from the final executable.
Package testutils contains files that are used in tests but not elsewhere and thus can be excluded from the final executable.

Jump to

Keyboard shortcuts

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