dockerapi

package
v1.23.0 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2018 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// CreateContainerTimeout is the timeout for the CreateContainer API.
	CreateContainerTimeout = 4 * time.Minute
	// StopContainerTimeout is the timeout for the StopContainer API.
	StopContainerTimeout = 30 * time.Second
	// RemoveContainerTimeout is the timeout for the RemoveContainer API.
	RemoveContainerTimeout = 5 * time.Minute
	// InspectContainerTimeout is the timeout for the InspectContainer API.
	InspectContainerTimeout = 30 * time.Second
	// RemoveImageTimeout is the timeout for the RemoveImage API.
	RemoveImageTimeout = 3 * time.Minute
	// ListPluginsTimeout is the timout for ListPlugins API.
	ListPluginsTimeout = 1 * time.Minute
	// CreateVolumeTimeout is the timout for CreateVolume API.
	CreateVolumeTimeout = 5 * time.Minute
	// InspectVolumeTimeout is the timout for InspectVolume API.
	InspectVolumeTimeout = 5 * time.Minute
	// RemoveVolumeTimeout is the timout for RemoveVolume API.
	RemoveVolumeTimeout = 5 * time.Minute

	// StatsInactivityTimeout controls the amount of time we hold open a
	// connection to the Docker daemon waiting for stats data
	StatsInactivityTimeout = 5 * time.Second
)

Timelimits for docker operations enforced above docker TODO: Make these limits configurable.

View Source
const (
	// DockerTimeoutErrorName is the name of docker timeout error.
	DockerTimeoutErrorName = "DockerTimeoutError"
	// CannotInspectContainerErrorName is the name of container inspect error.
	CannotInspectContainerErrorName = "CannotInspectContainerError"
	// CannotDescribeContainerErrorName is the name of describe container error.
	CannotDescribeContainerErrorName = "CannotDescribeContainerError"
)
View Source
const (

	// VolumeDriverType is one of the plugin capabilities see https://docs.docker.com/engine/reference/commandline/plugin_ls/#filtering
	VolumeDriverType = "volumedriver"
)

Variables

This section is empty.

Functions

func DockerStateToState

func DockerStateToState(state docker.State) apicontainerstatus.ContainerStatus

DockerStateToState converts the container status from docker to status recognized by the agent Ref: https://github.com/fsouza/go-dockerclient/blob/fd53184a1439b6d7b82ca54c1cd9adac9a5278f2/container.go#L133

Types

type CannotCreateContainerError

type CannotCreateContainerError struct {
	FromError error
}

CannotCreateContainerError indicates any error when trying to create a container

func (CannotCreateContainerError) Error

func (err CannotCreateContainerError) Error() string

func (CannotCreateContainerError) ErrorName

func (err CannotCreateContainerError) ErrorName() string

ErrorName returns name of the CannotCreateContainerError.

type CannotCreateVolumeError added in v1.19.0

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

CannotCreateVolumeError indicates any error when trying to create a volume

func (CannotCreateVolumeError) Error added in v1.19.0

func (err CannotCreateVolumeError) Error() string

func (CannotCreateVolumeError) ErrorName added in v1.19.0

func (err CannotCreateVolumeError) ErrorName() string

type CannotDescribeContainerError

type CannotDescribeContainerError struct {
	FromError error
}

CannotDescribeContainerError indicates any error when trying to describe a container

func (CannotDescribeContainerError) Error

func (CannotDescribeContainerError) ErrorName

func (err CannotDescribeContainerError) ErrorName() string

ErrorName returns name of the CannotDescribeContainerError

type CannotGetDockerClientError

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

CannotGetDockerClientError is a type for failing to get a specific Docker client

func (CannotGetDockerClientError) Error

func (CannotGetDockerClientError) ErrorName

func (CannotGetDockerClientError) ErrorName() string

ErrorName returns the name of the CannotGetDockerClientError.

type CannotInspectContainerError

type CannotInspectContainerError struct {
	FromError error
}

CannotInspectContainerError indicates any error when trying to inspect a container

func (CannotInspectContainerError) Error

func (err CannotInspectContainerError) Error() string

func (CannotInspectContainerError) ErrorName

func (err CannotInspectContainerError) ErrorName() string

ErrorName returns name of the CannotInspectContainerError

type CannotInspectVolumeError added in v1.19.0

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

CannotInspectVolumeError indicates any error when trying to inspect a volume

func (CannotInspectVolumeError) Error added in v1.19.0

func (err CannotInspectVolumeError) Error() string

func (CannotInspectVolumeError) ErrorName added in v1.19.0

func (err CannotInspectVolumeError) ErrorName() string

type CannotListContainersError

type CannotListContainersError struct {
	FromError error
}

CannotListContainersError indicates any error when trying to list containers

func (CannotListContainersError) Error

func (err CannotListContainersError) Error() string

func (CannotListContainersError) ErrorName

func (err CannotListContainersError) ErrorName() string

ErrorName returns name of the CannotListContainersError

type CannotListPluginsError added in v1.19.0

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

CannotListPluginsError indicates any error when trying to list docker plugins

func (CannotListPluginsError) Error added in v1.19.0

func (err CannotListPluginsError) Error() string

func (CannotListPluginsError) ErrorName added in v1.19.0

func (err CannotListPluginsError) ErrorName() string

type CannotPullContainerAuthError added in v1.19.0

type CannotPullContainerAuthError struct {
	FromError error
}

CannotPullContainerAuthError indicates any error when trying to pull a container image

func (CannotPullContainerAuthError) Error added in v1.19.0

func (CannotPullContainerAuthError) ErrorName added in v1.19.0

func (err CannotPullContainerAuthError) ErrorName() string

ErrorName returns name of the CannotPullContainerAuthError.

func (CannotPullContainerAuthError) Retry added in v1.19.0

func (err CannotPullContainerAuthError) Retry() bool

Retry fulfills the utils.Retrier interface and allows retries to be skipped by utils.Retry* functions

type CannotPullContainerError

type CannotPullContainerError struct {
	FromError error
}

CannotPullContainerError indicates any error when trying to pull a container image

func (CannotPullContainerError) Error

func (err CannotPullContainerError) Error() string

func (CannotPullContainerError) ErrorName

func (err CannotPullContainerError) ErrorName() string

ErrorName returns name of the CannotPullContainerError.

type CannotPullECRContainerError

type CannotPullECRContainerError struct {
	FromError error
}

CannotPullECRContainerError indicates any error when trying to pull a container image from ECR

func (CannotPullECRContainerError) Error

func (err CannotPullECRContainerError) Error() string

func (CannotPullECRContainerError) ErrorName

func (err CannotPullECRContainerError) ErrorName() string

ErrorName returns name of the CannotPullECRContainerError.

func (CannotPullECRContainerError) Retry

func (err CannotPullECRContainerError) Retry() bool

Retry fulfills the utils.Retrier interface and allows retries to be skipped by utils.Retry* functions

type CannotRemoveContainerError

type CannotRemoveContainerError struct {
	FromError error
}

CannotRemoveContainerError indicates any error when trying to remove a container

func (CannotRemoveContainerError) Error

func (err CannotRemoveContainerError) Error() string

func (CannotRemoveContainerError) ErrorName

func (err CannotRemoveContainerError) ErrorName() string

ErrorName returns name of the CannotRemoveContainerError

type CannotRemoveVolumeError added in v1.19.0

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

CannotRemoveVolumeError indicates any error when trying to inspect a volume

func (CannotRemoveVolumeError) Error added in v1.19.0

func (err CannotRemoveVolumeError) Error() string

func (CannotRemoveVolumeError) ErrorName added in v1.19.0

func (err CannotRemoveVolumeError) ErrorName() string

type CannotStartContainerError

type CannotStartContainerError struct {
	FromError error
}

CannotStartContainerError indicates any error when trying to start a container

func (CannotStartContainerError) Error

func (err CannotStartContainerError) Error() string

func (CannotStartContainerError) ErrorName

func (err CannotStartContainerError) ErrorName() string

ErrorName returns name of the CannotStartContainerError

type CannotStopContainerError

type CannotStopContainerError struct {
	FromError error
}

CannotStopContainerError indicates any error when trying to stop a container

func (CannotStopContainerError) Error

func (err CannotStopContainerError) Error() string

func (CannotStopContainerError) ErrorName

func (err CannotStopContainerError) ErrorName() string

ErrorName returns name of the CannotStopContainerError.

func (CannotStopContainerError) IsRetriableError

func (err CannotStopContainerError) IsRetriableError() bool

IsRetriableError returns a boolean indicating whether the call that generated the error can be retried. When stopping a container, most errors that we can get should be considered retriable. However, in the case where the container is already stopped or doesn't exist at all, there's no sense in retrying.

type ContainerNotFound

type ContainerNotFound struct {
	// TaskArn is the ARN of the task the container belongs to
	TaskArn string
	// ContainerName is the name of the container that's missing
	ContainerName string
}

ContainerNotFound is a type for a missing container

func (ContainerNotFound) Error

func (cnferror ContainerNotFound) Error() string

Error returns an error string for the ContainerNotFound error

type DockerClient

type DockerClient interface {
	// SupportedVersions returns a slice of the supported docker versions (or at least supposedly supported).
	SupportedVersions() []dockerclient.DockerVersion

	// KnownVersions returns a slice of the Docker API versions known to the Docker daemon.
	KnownVersions() []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 returns a channel of DockerContainerChangeEvents. Events are placed into the channel and should
	// be processed by the listener.
	ContainerEvents(ctx context.Context) (<-chan DockerContainerChangeEvent, error)

	// PullImage pulls an image. authData should contain authentication data provided by the ECS backend.
	PullImage(image string, authData *apicontainer.RegistryAuthenticationData) DockerContainerMetadata

	// CreateContainer creates a container with the provided docker.Config, docker.HostConfig, and name. A timeout value
	// and a context should be provided for the request.
	CreateContainer(context.Context, *docker.Config, *docker.HostConfig, string, time.Duration) DockerContainerMetadata

	// StartContainer starts the container identified by the name provided. A timeout value and a context should be
	// provided for the request.
	StartContainer(context.Context, string, time.Duration) DockerContainerMetadata

	// StopContainer stops the container identified by the name provided. A timeout value and a context should be provided
	// for the request.
	StopContainer(context.Context, string, time.Duration) DockerContainerMetadata

	// DescribeContainer returns status information about the specified container. A context should be provided
	// for the request
	DescribeContainer(context.Context, string) (apicontainerstatus.ContainerStatus, DockerContainerMetadata)

	// RemoveContainer removes a container (typically the rootfs, logs, and associated metadata) identified by the name.
	// A timeout value and a context should be provided for the request.
	RemoveContainer(context.Context, string, time.Duration) error

	// InspectContainer returns information about the specified container. A timeout value and a context should be
	// provided for the request.
	InspectContainer(context.Context, string, time.Duration) (*docker.Container, error)

	// ListContainers returns the set of containers known to the Docker daemon. A timeout value and a context
	// should be provided for the request.
	ListContainers(context.Context, bool, time.Duration) ListContainersResponse

	// CreateVolume creates a docker volume. A timeout value should be provided for the request
	CreateVolume(context.Context, string, string, map[string]string, map[string]string, time.Duration) VolumeResponse

	// InspectVolume returns a volume by its name. A timeout value should be provided for the request
	InspectVolume(context.Context, string, time.Duration) VolumeResponse

	// RemoveVolume removes a volume by its name. A timeout value should be provided for the request
	RemoveVolume(context.Context, string, time.Duration) error

	// ListPluginsWithFilters returns the set of docker plugins installed on the host, filtered by options provided.
	// A timeout value should be provided for the request.
	ListPluginsWithFilters(context.Context, bool, []string, time.Duration) ([]string, error)

	// ListPlugins returns the set of docker plugins installed on the host. A timeout value should be provided for
	// the request.
	ListPlugins(context.Context, time.Duration) ListPluginsResponse

	// Stats returns a channel of stat data for the specified container. A context should be provided so the request can
	// be canceled.
	Stats(string, context.Context) (<-chan *docker.Stats, error)

	// Version returns the version of the Docker daemon.
	Version(context.Context, time.Duration) (string, error)

	// APIVersion returns the api version of the client
	APIVersion() (dockerclient.DockerVersion, error)

	// InspectImage returns information about the specified image.
	InspectImage(string) (*docker.Image, error)

	// RemoveImage removes the metadata associated with an image and may remove the underlying layer data. A timeout
	// value and a context should be provided for the request.
	RemoveImage(context.Context, string, time.Duration) error
	// LoadImage loads an image from an input stream. A timeout value and a context should be provided for the request.
	LoadImage(context.Context, io.Reader, time.Duration) error
}

DockerClient interface to make testing it easier

func NewDockerGoClient

func NewDockerGoClient(clientFactory clientfactory.Factory, cfg *config.Config) (DockerClient, error)

NewDockerGoClient creates a new DockerGoClient

type DockerContainerChangeEvent

type DockerContainerChangeEvent struct {
	// Status represents the container's status in the event
	Status apicontainerstatus.ContainerStatus
	// DockerContainerMetadata is the metadata of the container in the event
	DockerContainerMetadata
	// Type is the event type received from docker events
	Type apicontainer.DockerEventType
}

DockerContainerChangeEvent is a type for container change events

func (*DockerContainerChangeEvent) String

func (event *DockerContainerChangeEvent) String() string

String returns a human readable string of the container change event

type DockerContainerMetadata

type DockerContainerMetadata struct {
	// DockerID is the contianer's id generated by Docker
	DockerID string
	// ExitCode contains container's exit code if it has stopped
	ExitCode *int
	// PortBindings is the list of port binding information of the container
	PortBindings []apicontainer.PortBinding
	// Error wraps various container transition errors and is set if engine
	// is unable to perform any of the required container transitions
	Error apierrors.NamedError
	// Volumes contains volume informaton for the container
	Volumes []docker.Mount
	// Labels contains labels set for the container
	Labels map[string]string
	// CreatedAt is the timestamp of container creation
	CreatedAt time.Time
	// StartedAt is the timestamp of container start
	StartedAt time.Time
	// FinishedAt is the timestamp of container stop
	FinishedAt time.Time
	// Health contains the result of a container health check
	Health apicontainer.HealthStatus
}

DockerContainerMetadata is a type for metadata about Docker containers

func MetadataFromContainer

func MetadataFromContainer(dockerContainer *docker.Container) DockerContainerMetadata

MetadataFromContainer translates dockerContainer into DockerContainerMetadata

type DockerStateError

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

func NewDockerStateError(err string) DockerStateError

NewDockerStateError creates a DockerStateError

func (DockerStateError) Error

func (err DockerStateError) Error() string

func (DockerStateError) ErrorName

func (err DockerStateError) ErrorName() string

ErrorName returns the name of the DockerStateError.

type DockerTimeoutError

type DockerTimeoutError struct {
	// Duration is the timeout period.
	Duration time.Duration
	// Transition is the description of operation that timed out.
	Transition string
}

DockerTimeoutError is an error type for describing timeouts

func (*DockerTimeoutError) Error

func (err *DockerTimeoutError) Error() string

func (*DockerTimeoutError) ErrorName

func (err *DockerTimeoutError) ErrorName() string

ErrorName returns the name of the error

type InfiniteBuffer

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

InfiniteBuffer defines an unlimited buffer, where it reads from input channel and write to output channel.

func NewInfiniteBuffer

func NewInfiniteBuffer() *InfiniteBuffer

NewInfiniteBuffer returns an InfiniteBuffer object

func (*InfiniteBuffer) Consume

func (buffer *InfiniteBuffer) Consume(in chan<- *docker.APIEvents)

Consume reads the buffer and write to a listener channel

func (*InfiniteBuffer) CopyEvents

func (buffer *InfiniteBuffer) CopyEvents(event *docker.APIEvents)

CopyEvents copies the event into the buffer

func (*InfiniteBuffer) StartListening

func (buffer *InfiniteBuffer) StartListening(events chan *docker.APIEvents)

StartListening starts reading from the input channel and writes to the buffer TODO: wire in ctx to stop listening

type ListContainersResponse

type ListContainersResponse struct {
	// DockerIDs is the list of container IDs from the ListContainers call
	DockerIDs []string
	// Error contains any error returned when listing containers
	Error error
}

ListContainersResponse encapsulates the response from the docker client for the ListContainers call.

type ListPluginsResponse added in v1.19.0

type ListPluginsResponse struct {
	Plugins []docker.PluginDetail
	Error   error
}

ListPluginsResponse is a wrapper for ListPlugins api

type OutOfMemoryError

type OutOfMemoryError struct{}

OutOfMemoryError is a type for errors caused by running out of memory

func (OutOfMemoryError) Error

func (err OutOfMemoryError) Error() string

func (OutOfMemoryError) ErrorName

func (err OutOfMemoryError) ErrorName() string

ErrorName returns the name of the error

type VolumeResponse added in v1.19.0

type VolumeResponse struct {
	DockerVolume *docker.Volume
	Error        error
}

VolumeResponse wrapper for CreateVolume and InspectVolume

Directories

Path Synopsis
Package mock_dockerapi is a generated GoMock package.
Package mock_dockerapi is a generated GoMock package.

Jump to

Keyboard shortcuts

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