Documentation ¶
Overview ¶
The 'engine' package contains code for interacting with container-running backends and handling events from them. It supports Docker as the sole task engine type.
The DockerTaskEngine is an abstraction over the DockerGoClient so that it does not have to know about tasks, only containers
Index ¶
- Constants
- type CannotGetDockerClientError
- type CannotXContainerError
- type ContainerNotFound
- type ContainerVanishedError
- type DockerClient
- type DockerContainerChangeEvent
- type DockerContainerMetadata
- type DockerImageResponse
- type DockerStateError
- type DockerTaskEngine
- func (engine *DockerTaskEngine) AddTask(task *api.Task) error
- func (engine *DockerTaskEngine) Capabilities() []string
- func (engine *DockerTaskEngine) CheckTaskState(task *api.Task)
- func (engine *DockerTaskEngine) Disable()
- func (engine *DockerTaskEngine) GetTaskByArn(arn string) (*api.Task, bool)
- func (engine *DockerTaskEngine) Init() error
- func (engine *DockerTaskEngine) ListTasks() ([]*api.Task, error)
- func (engine *DockerTaskEngine) MarshalJSON() ([]byte, error)
- func (engine *DockerTaskEngine) MustInit()
- func (engine *DockerTaskEngine) SetDockerClient(client DockerClient)
- func (engine *DockerTaskEngine) SetSaver(saver statemanager.Saver)
- func (engine *DockerTaskEngine) Shutdown()
- func (engine *DockerTaskEngine) State() *dockerstate.DockerTaskEngineState
- func (engine *DockerTaskEngine) TaskEvents() (<-chan api.TaskStateChange, <-chan api.ContainerStateChange)
- func (engine *DockerTaskEngine) UnmarshalJSON(data []byte) error
- func (engine *DockerTaskEngine) Version() (string, error)
- type DockerTimeoutError
- type ListContainersResponse
- type MockDockerClient
- func (_m *MockDockerClient) ContainerEvents(_param0 context.Context) (<-chan DockerContainerChangeEvent, error)
- func (_m *MockDockerClient) CreateContainer(_param0 *go_dockerclient.Config, _param1 *go_dockerclient.HostConfig, ...) DockerContainerMetadata
- func (_m *MockDockerClient) DescribeContainer(_param0 string) (api.ContainerStatus, DockerContainerMetadata)
- func (_m *MockDockerClient) EXPECT() *_MockDockerClientRecorder
- func (_m *MockDockerClient) InspectContainer(_param0 string) (*go_dockerclient.Container, error)
- func (_m *MockDockerClient) ListContainers(_param0 bool) ListContainersResponse
- func (_m *MockDockerClient) PullImage(_param0 string, _param1 *api.RegistryAuthenticationData) DockerContainerMetadata
- func (_m *MockDockerClient) RemoveContainer(_param0 string) error
- func (_m *MockDockerClient) StartContainer(_param0 string) DockerContainerMetadata
- func (_m *MockDockerClient) Stats(_param0 string, _param1 context.Context) (<-chan *go_dockerclient.Stats, error)
- func (_m *MockDockerClient) StopContainer(_param0 string) DockerContainerMetadata
- func (_m *MockDockerClient) SupportedVersions() []dockerclient.DockerVersion
- func (_m *MockDockerClient) Version() (string, error)
- func (_m *MockDockerClient) WithVersion(_param0 dockerclient.DockerVersion) DockerClient
- type MockTaskEngine
- func (_m *MockTaskEngine) AddTask(_param0 *api.Task) error
- func (_m *MockTaskEngine) Capabilities() []string
- func (_m *MockTaskEngine) Disable()
- func (_m *MockTaskEngine) EXPECT() *_MockTaskEngineRecorder
- func (_m *MockTaskEngine) GetTaskByArn(_param0 string) (*api.Task, bool)
- func (_m *MockTaskEngine) Init() error
- func (_m *MockTaskEngine) ListTasks() ([]*api.Task, error)
- func (_m *MockTaskEngine) MarshalJSON() ([]byte, error)
- func (_m *MockTaskEngine) MustInit()
- func (_m *MockTaskEngine) SetSaver(_param0 statemanager.Saver)
- func (_m *MockTaskEngine) TaskEvents() (<-chan api.TaskStateChange, <-chan api.ContainerStateChange)
- func (_m *MockTaskEngine) UnmarshalJSON(_param0 []byte) error
- func (_m *MockTaskEngine) Version() (string, error)
- type OutOfMemoryError
- type TaskEngine
Constants ¶
const ( DOCKER_ENDPOINT_ENV_VARIABLE = "DOCKER_HOST" DOCKER_DEFAULT_ENDPOINT = "unix:///var/run/docker.sock" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CannotGetDockerClientError ¶ added in v1.5.0
type CannotGetDockerClientError struct {
// contains filtered or unexported fields
}
func (CannotGetDockerClientError) Error ¶ added in v1.5.0
func (c CannotGetDockerClientError) Error() string
func (CannotGetDockerClientError) ErrorName ¶ added in v1.5.0
func (CannotGetDockerClientError) ErrorName() string
type CannotXContainerError ¶ added in v1.1.0
type CannotXContainerError struct {
// contains filtered or unexported fields
}
func (CannotXContainerError) Error ¶ added in v1.1.0
func (err CannotXContainerError) Error() string
func (CannotXContainerError) ErrorName ¶ added in v1.1.0
func (err CannotXContainerError) ErrorName() string
type ContainerNotFound ¶
func (ContainerNotFound) Error ¶
func (cnferror ContainerNotFound) Error() string
type ContainerVanishedError ¶ added in v1.1.0
type ContainerVanishedError struct{}
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
type DockerClient ¶
type DockerClient interface { // SupportedVersions returns a slice of the supported docker versions (or at least supposedly supported). SupportedVersions() []dockerclient.DockerVersion // WithVersion returns a new DockerClient for which all operations will use the given remote api version. // A default version will be used for a client not produced via this method. WithVersion(dockerclient.DockerVersion) DockerClient ContainerEvents(ctx context.Context) (<-chan DockerContainerChangeEvent, error) PullImage(image string, authData *api.RegistryAuthenticationData) DockerContainerMetadata CreateContainer(*docker.Config, *docker.HostConfig, string) DockerContainerMetadata StartContainer(string) DockerContainerMetadata StopContainer(string) DockerContainerMetadata DescribeContainer(string) (api.ContainerStatus, DockerContainerMetadata) RemoveContainer(string) error InspectContainer(string) (*docker.Container, error) ListContainers(bool) ListContainersResponse Stats(string, context.Context) (<-chan *docker.Stats, error) Version() (string, error) }
Interface to make testing it easier
func NewDockerGoClient ¶
func NewDockerGoClient(clientFactory dockerclient.Factory, acceptInsecureCert bool, cfg *config.Config) (DockerClient, error)
NewDockerGoClient creates a new DockerGoClient
type DockerContainerChangeEvent ¶
type DockerContainerChangeEvent struct { Status api.ContainerStatus DockerContainerMetadata }
type DockerContainerMetadata ¶ added in v1.1.0
type DockerImageResponse ¶
type DockerStateError ¶ added in v1.1.0
type DockerStateError struct {
// contains filtered or unexported fields
}
DockerStateError is a wrapper around the error docker puts in the '.State.Error' field of its inspect output.
func NewDockerStateError ¶ added in v1.1.0
func NewDockerStateError(err string) DockerStateError
func (DockerStateError) Error ¶ added in v1.1.0
func (err DockerStateError) Error() string
func (DockerStateError) ErrorName ¶ added in v1.1.0
func (err DockerStateError) ErrorName() string
type DockerTaskEngine ¶
type DockerTaskEngine struct {
// contains filtered or unexported fields
}
The DockerTaskEngine interacts with docker to implement a task engine
func NewDockerTaskEngine ¶
func NewDockerTaskEngine(cfg *config.Config, client DockerClient, credentialsManager credentials.Manager) *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) Capabilities ¶ added in v1.5.0
func (engine *DockerTaskEngine) Capabilities() []string
Capabilities returns the supported capabilities of this agent / docker-client pair. Currently, the following capabilities are possible:
com.amazonaws.ecs.capability.privileged-container com.amazonaws.ecs.capability.docker-remote-api.1.17 com.amazonaws.ecs.capability.docker-remote-api.1.18 com.amazonaws.ecs.capability.docker-remote-api.1.19 com.amazonaws.ecs.capability.docker-remote-api.1.20 com.amazonaws.ecs.capability.logging-driver.json-file com.amazonaws.ecs.capability.logging-driver.syslog com.amazonaws.ecs.capability.logging-driver.fluentd com.amazonaws.ecs.capability.logging-driver.journald com.amazonaws.ecs.capability.logging-driver.gelf com.amazonaws.ecs.capability.selinux com.amazonaws.ecs.capability.apparmor com.amazonaws.ecs.capability.ecr-auth com.amazonaws.ecs.capability.task-iam-role com.amazonaws.ecs.capability.task-iam-role-network-host
func (*DockerTaskEngine) CheckTaskState ¶ added in v1.1.0
func (engine *DockerTaskEngine) CheckTaskState(task *api.Task)
CheckTaskState inspects the state of all containers within a task and writes their state to the managed task's container channel.
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) (*api.Task, bool)
func (*DockerTaskEngine) Init ¶
func (engine *DockerTaskEngine) Init() 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() ([]*api.Task, error)
func (*DockerTaskEngine) MarshalJSON ¶
func (engine *DockerTaskEngine) MarshalJSON() ([]byte, error)
MarshalJSON marshals into state directly
func (*DockerTaskEngine) MustInit ¶
func (engine *DockerTaskEngine) MustInit()
MustInit blocks and retries until an engine can be initialized.
func (*DockerTaskEngine) SetDockerClient ¶ added in v1.1.0
func (engine *DockerTaskEngine) SetDockerClient(client DockerClient)
SetDockerClient provides a way to override the client used for communication with docker as a testing hook.
func (*DockerTaskEngine) SetSaver ¶
func (engine *DockerTaskEngine) SetSaver(saver statemanager.Saver)
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 ¶
func (engine *DockerTaskEngine) State() *dockerstate.DockerTaskEngineState
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) TaskEvents ¶
func (engine *DockerTaskEngine) TaskEvents() (<-chan api.TaskStateChange, <-chan api.ContainerStateChange)
TaskEvents 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 DockerTimeoutError ¶ added in v1.1.0
type DockerTimeoutError struct {
// contains filtered or unexported fields
}
func (*DockerTimeoutError) Error ¶ added in v1.1.0
func (err *DockerTimeoutError) Error() string
func (*DockerTimeoutError) ErrorName ¶ added in v1.1.0
func (err *DockerTimeoutError) ErrorName() string
type ListContainersResponse ¶ added in v1.2.0
ListContainersResponse encapsulates the response from the docker client for the ListContainers call.
type MockDockerClient ¶ added in v1.7.0
type MockDockerClient struct {
// contains filtered or unexported fields
}
Mock of DockerClient interface
func NewMockDockerClient ¶ added in v1.7.0
func NewMockDockerClient(ctrl *gomock.Controller) *MockDockerClient
func (*MockDockerClient) ContainerEvents ¶ added in v1.7.0
func (_m *MockDockerClient) ContainerEvents(_param0 context.Context) (<-chan DockerContainerChangeEvent, error)
func (*MockDockerClient) CreateContainer ¶ added in v1.7.0
func (_m *MockDockerClient) CreateContainer(_param0 *go_dockerclient.Config, _param1 *go_dockerclient.HostConfig, _param2 string) DockerContainerMetadata
func (*MockDockerClient) DescribeContainer ¶ added in v1.7.0
func (_m *MockDockerClient) DescribeContainer(_param0 string) (api.ContainerStatus, DockerContainerMetadata)
func (*MockDockerClient) EXPECT ¶ added in v1.7.0
func (_m *MockDockerClient) EXPECT() *_MockDockerClientRecorder
func (*MockDockerClient) InspectContainer ¶ added in v1.7.0
func (_m *MockDockerClient) InspectContainer(_param0 string) (*go_dockerclient.Container, error)
func (*MockDockerClient) ListContainers ¶ added in v1.7.0
func (_m *MockDockerClient) ListContainers(_param0 bool) ListContainersResponse
func (*MockDockerClient) PullImage ¶ added in v1.7.0
func (_m *MockDockerClient) PullImage(_param0 string, _param1 *api.RegistryAuthenticationData) DockerContainerMetadata
func (*MockDockerClient) RemoveContainer ¶ added in v1.7.0
func (_m *MockDockerClient) RemoveContainer(_param0 string) error
func (*MockDockerClient) StartContainer ¶ added in v1.7.0
func (_m *MockDockerClient) StartContainer(_param0 string) DockerContainerMetadata
func (*MockDockerClient) Stats ¶ added in v1.10.0
func (_m *MockDockerClient) Stats(_param0 string, _param1 context.Context) (<-chan *go_dockerclient.Stats, error)
func (*MockDockerClient) StopContainer ¶ added in v1.7.0
func (_m *MockDockerClient) StopContainer(_param0 string) DockerContainerMetadata
func (*MockDockerClient) SupportedVersions ¶ added in v1.7.0
func (_m *MockDockerClient) SupportedVersions() []dockerclient.DockerVersion
func (*MockDockerClient) Version ¶ added in v1.7.0
func (_m *MockDockerClient) Version() (string, error)
func (*MockDockerClient) WithVersion ¶ added in v1.7.0
func (_m *MockDockerClient) WithVersion(_param0 dockerclient.DockerVersion) DockerClient
type MockTaskEngine ¶ added in v1.7.0
type MockTaskEngine struct {
// contains filtered or unexported fields
}
Mock of TaskEngine interface
func NewMockTaskEngine ¶ added in v1.7.0
func NewMockTaskEngine(ctrl *gomock.Controller) *MockTaskEngine
func (*MockTaskEngine) AddTask ¶ added in v1.7.0
func (_m *MockTaskEngine) AddTask(_param0 *api.Task) error
func (*MockTaskEngine) Capabilities ¶ added in v1.7.0
func (_m *MockTaskEngine) Capabilities() []string
func (*MockTaskEngine) Disable ¶ added in v1.7.0
func (_m *MockTaskEngine) Disable()
func (*MockTaskEngine) EXPECT ¶ added in v1.7.0
func (_m *MockTaskEngine) EXPECT() *_MockTaskEngineRecorder
func (*MockTaskEngine) GetTaskByArn ¶ added in v1.8.2
func (_m *MockTaskEngine) GetTaskByArn(_param0 string) (*api.Task, bool)
func (*MockTaskEngine) Init ¶ added in v1.7.0
func (_m *MockTaskEngine) Init() error
func (*MockTaskEngine) ListTasks ¶ added in v1.7.0
func (_m *MockTaskEngine) ListTasks() ([]*api.Task, error)
func (*MockTaskEngine) MarshalJSON ¶ added in v1.7.0
func (_m *MockTaskEngine) MarshalJSON() ([]byte, error)
func (*MockTaskEngine) MustInit ¶ added in v1.7.0
func (_m *MockTaskEngine) MustInit()
func (*MockTaskEngine) SetSaver ¶ added in v1.7.0
func (_m *MockTaskEngine) SetSaver(_param0 statemanager.Saver)
func (*MockTaskEngine) TaskEvents ¶ added in v1.7.0
func (_m *MockTaskEngine) TaskEvents() (<-chan api.TaskStateChange, <-chan api.ContainerStateChange)
func (*MockTaskEngine) UnmarshalJSON ¶ added in v1.7.0
func (_m *MockTaskEngine) UnmarshalJSON(_param0 []byte) error
func (*MockTaskEngine) Version ¶ added in v1.7.0
func (_m *MockTaskEngine) Version() (string, error)
type OutOfMemoryError ¶ added in v1.1.0
type OutOfMemoryError struct{}
func (OutOfMemoryError) Error ¶ added in v1.1.0
func (err OutOfMemoryError) Error() string
func (OutOfMemoryError) ErrorName ¶ added in v1.1.0
func (err OutOfMemoryError) ErrorName() string
type TaskEngine ¶
type TaskEngine interface { Init() error MustInit() // Disable *must* only be called when this engine will no longer be used // (e.g. right before exiting down the process). It will irreversably stop // this task engine from processing new tasks Disable() // TaskEvents 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 TaskEvents() (<-chan api.TaskStateChange, <-chan api.ContainerStateChange) SetSaver(statemanager.Saver) // 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(*api.Task) error // ListTasks lists all the tasks being managed by the TaskEngine. ListTasks() ([]*api.Task, error) // GetTaskByArn gets a managed task, given a task arn. GetTaskByArn(string) (*api.Task, bool) Version() (string, error) // Capabilities returns an array of capabilities this task engine has, which // should model what it can execute. Capabilities() []string json.Marshaler json.Unmarshaler }
func NewTaskEngine ¶
func NewTaskEngine(cfg *config.Config, client DockerClient, credentialsManager credentials.Manager) TaskEngine
NewTaskEngine returns a default TaskEngine
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package dockerauth handles storing auth configuration information for Docker registries.
|
Package dockerauth handles storing auth configuration information for Docker registries. |
Package dockeriface contains an interface for go-dockerclient matching the subset used by the agent
|
Package dockeriface contains an interface for go-dockerclient matching the subset used by the agent |
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 emptyvolume contains some information related to the 'emptyvolumes'
|
Package emptyvolume contains some information related to the 'emptyvolumes' |
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. |