api

package
v1.14.5 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2017 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 4 more Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UnrecognizedTransportProtocolErrorName = "UnrecognizedTransportProtocol"
	UnparseablePortErrorName               = "UnparsablePort"
)
View Source
const (
	// DockerContainerMinimumMemoryInBytes is the minimum amount of
	// memory to be allocated to a docker container
	DockerContainerMinimumMemoryInBytes = 4 * 1024 * 1024 // 4MB

)
View Source
const InstanceTypeChangedErrorMessage = "Container instance type changes are not supported."

InstanceTypeChangedErrorMessage is the error message to print for the instance type changed error when registering a container instance

View Source
const OSType = "linux"
View Source
const (
	// PauseContainerName is the internal name for the pause container
	PauseContainerName = "~internal~ecs~pause"
)

Variables

This section is empty.

Functions

func IsInstanceTypeChangedError added in v1.3.1

func IsInstanceTypeChangedError(err error) bool

IsInstanceTypeChangedError returns true if the error when registering the container instance is because of instance type being changed

func PortBindingFromDockerPortBinding

func PortBindingFromDockerPortBinding(dockerPortBindings map[docker.Port][]docker.PortBinding) ([]PortBinding, NamedError)

PortBindingFromDockerPortBinding constructs a PortBinding slice from a docker NetworkSettings.Ports map.

func ValidateTaskENI added in v1.14.5

func ValidateTaskENI(acsenis []*ecsacs.ElasticNetworkInterface) error

ValidateTaskENI validates the eni informaiton sent from acs

Types

type Container

type Container struct {
	// Name is the name of the container specified in the task definition
	Name string
	// Image is the image name specified in the task definition
	Image string
	// ImageID is the local ID of the image used in the container
	ImageID string

	Command                []string
	CPU                    uint `json:"Cpu"`
	Memory                 uint
	Links                  []string
	VolumesFrom            []VolumeFrom  `json:"volumesFrom"`
	MountPoints            []MountPoint  `json:"mountPoints"`
	Ports                  []PortBinding `json:"portMappings"`
	Essential              bool
	EntryPoint             *[]string
	Environment            map[string]string           `json:"environment"`
	Overrides              ContainerOverrides          `json:"overrides"`
	DockerConfig           DockerConfig                `json:"dockerConfig"`
	RegistryAuthentication *RegistryAuthenticationData `json:"registryAuthentication"`

	// DesiredStatusUnsafe represents the state where the container should go. Generally,
	// the desired status is informed by the ECS backend as a result of either
	// API calls made to ECS or decisions made by the ECS service scheduler,
	// though the agent may also set the DesiredStatusUnsafe if a different "essential"
	// container in the task exits. The DesiredStatus is almost always either
	// ContainerRunning or ContainerStopped.
	// NOTE: Do not access DesiredStatusUnsafe directly.  Instead, use `GetDesiredStatus`
	// and `SetDesiredStatus`.
	// TODO DesiredStatusUnsafe should probably be private with appropriately written
	// setter/getter.  When this is done, we need to ensure that the UnmarshalJSON
	// is handled properly so that the state storage continues to work.
	DesiredStatusUnsafe ContainerStatus `json:"desiredStatus"`

	// KnownStatusUnsafe represents the state where the container is.
	// NOTE: Do not access `KnownStatusUnsafe` directly.  Instead, use `GetKnownStatus`
	// and `SetKnownStatus`.
	// TODO KnownStatusUnsafe should probably be private with appropriately written
	// setter/getter.  When this is done, we need to ensure that the UnmarshalJSON
	// is handled properly so that the state storage continues to work.
	KnownStatusUnsafe ContainerStatus `json:"KnownStatus"`

	// TransitionDependencySet is a set of dependencies that must be satisfied
	// in order for this container to transition.  Each transition dependency
	// specifies a resource upon which the transition is dependent, a status
	// that depends on the resource, and the state of the dependency that
	// satisfies.
	TransitionDependencySet TransitionDependencySet `json:"TransitionDependencySet"`

	// SteadyStateDependencies is a list of containers that must be in "steady state" before
	// this one is created
	// Note: Current logic requires that the containers specified here are run
	// before this container can even be pulled.
	//
	// Deprecated: Use TransitionDependencySet instead. SteadyStateDependencies is retained for compatibility with old
	// state files.
	SteadyStateDependencies []string `json:"RunDependencies"`

	// Type specifies the container type. Except the 'Normal' type, all other types
	// are not directly specified by task definitions, but created by the agent. The
	// JSON tag is retained as this field's previous name 'IsInternal' for maintaining
	// backwards compatibility. Please see JSON parsing hooks for this type for more
	// details
	Type ContainerType `json:"IsInternal"`

	// AppliedStatus is the status that has been "applied" (e.g., we've called Pull,
	// Create, Start, or Stop) but we don't yet know that the application was successful.
	AppliedStatus ContainerStatus
	// ApplyingError is an error that occured trying to transition the container
	// to its desired state. It is propagated to the backend in the form
	// 'Name: ErrorString' as the 'reason' field.
	ApplyingError *DefaultNamedError

	// SentStatusUnsafe represents the last KnownStatusUnsafe that was sent to the ECS
	// SubmitContainerStateChange API.
	// TODO SentStatusUnsafe should probably be private with appropriately written
	// setter/getter.  When this is done, we need to ensure that the UnmarshalJSON is
	// handled properly so that the state storage continues to work.
	SentStatusUnsafe ContainerStatus `json:"SentStatus"`

	KnownPortBindings []PortBinding

	// SteadyStateStatusUnsafe specifies the steady state status for the container
	// If uninitialized, it's assumed to be set to 'ContainerRunning'. Even though
	// it's not only supposed to be set when the container is being created, it's
	// exposed outside of the package so that it's marshalled/unmarshalled in the
	// the JSON body while saving the state
	SteadyStateStatusUnsafe *ContainerStatus `json:"SteadyStateStatus,omitempty"`
	// contains filtered or unexported fields
}

Container is the internal representation of a container in the ECS agent

func NewContainerWithSteadyState added in v1.14.5

func NewContainerWithSteadyState(steadyState ContainerStatus) *Container

NewContainerWithSteadyState creates a new Container object with the specified steady state. Containers that need the non default steady state set will use this method instead of setting it directly

func (*Container) DesiredTerminal

func (c *Container) DesiredTerminal() bool

DesiredTerminal returns true if the container's desired status is STOPPED

func (*Container) GetDesiredStatus added in v1.12.2

func (c *Container) GetDesiredStatus() ContainerStatus

GetDesiredStatus gets the desired status of the container

func (*Container) GetKnownExitCode added in v1.14.4

func (c *Container) GetKnownExitCode() *int

func (*Container) GetKnownStatus added in v1.12.2

func (c *Container) GetKnownStatus() ContainerStatus

GetKnownStatus returns the known status of the container

func (*Container) GetNextKnownStateProgression added in v1.14.5

func (c *Container) GetNextKnownStateProgression() ContainerStatus

GetNextKnownStateProgression returns the state that the container should progress to based on its `KnownState`. The progression is incremental until the container reaches its steady state. From then on, it transitions to `ContainerStopped`.

For example: a. if the steady state of the container is defined as `ContainerRunning`, the progression is: Container: None -> Pulled -> Created -> Running* -> Stopped -> Zombie

b. if the steady state of the container is defined as `ContainerResourcesProvisioned`, the progression is: Container: None -> Pulled -> Created -> Running -> Provisioned* -> Stopped -> Zombie

c. if the steady state of the container is defined as `ContainerCreated`, the progression is: Container: None -> Pulled -> Created* -> Stopped -> Zombie

func (*Container) GetSentStatus added in v1.14.1

func (c *Container) GetSentStatus() ContainerStatus

GetSentStatus safely returns the SentStatusUnsafe of the container

func (*Container) GetSteadyStateStatus added in v1.14.5

func (c *Container) GetSteadyStateStatus() ContainerStatus

GetSteadyStateStatus returns the steady state status for the container. If Container.steadyState is not initialized, the default steady state status defined by `defaultContainerSteadyStateStatus` is returned. The 'pause' container's steady state differs from that of other containers, as the 'pause' container can reach its teady state once networking resources have been provisioned for it, which is done in the `ContainerResourcesProvisioned` state

func (*Container) IsInternal

func (c *Container) IsInternal() bool

IsInternal returns true if the container type is either `ContainerEmptyHostVolume` or `ContainerCNIPause`. It returns false otherwise

func (*Container) IsKnownSteadyState added in v1.14.5

func (c *Container) IsKnownSteadyState() bool

IsKnownSteadyState returns true if the `KnownState` of the container equals the `steadyState` defined for the container

func (*Container) IsRunning added in v1.14.5

func (c *Container) IsRunning() bool

IsRunning returns true if the container's known status is either RUNNING or RESOURCES_PROVISIONED. It returns false otherwise

func (*Container) KnownTerminal

func (c *Container) KnownTerminal() bool

KnownTerminal returns true if the container's known status is STOPPED

func (*Container) Overridden

func (c *Container) Overridden() *Container

Overriden applies the overridden command and returns the resulting container object

func (*Container) SetDesiredStatus added in v1.12.2

func (c *Container) SetDesiredStatus(status ContainerStatus)

SetDesiredStatus sets the desired status of the container

func (*Container) SetKnownExitCode added in v1.14.4

func (c *Container) SetKnownExitCode(i *int)

func (*Container) SetKnownStatus added in v1.12.2

func (c *Container) SetKnownStatus(status ContainerStatus)

SetKnownStatus sets the known status of the container

func (*Container) SetSentStatus added in v1.14.1

func (c *Container) SetSentStatus(status ContainerStatus)

SetSentStatus safely sets the SentStatusUnsafe of the container

func (*Container) String

func (c *Container) String() string

String returns a human readable string representation of this object

type ContainerDependency added in v1.14.5

type ContainerDependency struct {
	// ContainerName defines the container on which a transition depends
	ContainerName string `json:"ContainerName"`
	// SatisfiedStatus defines the status that satisfies the dependency
	SatisfiedStatus ContainerStatus `json:"SatisfiedStatus"`
	// DependentStatus defines the status that cannot be reached until the
	// resource satisfies the dependency
	DependentStatus ContainerStatus `json:"DependentStatus"`
}

ContainerDependency defines the relationship between a dependent container and its dependency.

type ContainerOverrides

type ContainerOverrides struct {
	Command *[]string `json:"command"`
}

ContainerOverrides are overrides applied to the container

func (*ContainerOverrides) UnmarshalJSON

func (overrides *ContainerOverrides) UnmarshalJSON(b []byte) error

UnmarshalJSON overrides the logic for parsing the JSON-encoded ContainerOverrides data This custom unmarshaller is needed because the json sent to us as a string rather than a fully typed object. We support both formats in the hopes that one day everything will be fully typed Note: the `json:",string"` tag DOES NOT apply here; it DOES NOT work with struct types, only ints/floats/etc. We're basically doing that though We also intentionally fail if there are any keys we were unable to unmarshal into our struct

type ContainerOverridesCopy

type ContainerOverridesCopy ContainerOverrides

ContainerOverridesCopy is a type alias that doesn't have a custom unmarshaller so we can unmarshal ContainerOverrides data into something without recursing

type ContainerStateChange

type ContainerStateChange struct {
	// TaskArn is the unique identifier for the task
	TaskArn string
	// ContainerName is the name of the container
	ContainerName string
	// Status is the status to send
	Status ContainerStatus

	// Reason may contain details of why the container stopped
	Reason string
	// ExitCode is the exit code of the container, if available
	ExitCode *int
	// PortBindings are the details of the host ports picked for the specified
	// container ports
	PortBindings []PortBinding

	// Container is a pointer to the container involved in the state change that gives the event handler a hook into
	// storing what status was sent.  This is used to ensure the same event is handled only once.
	Container *Container
}

ContainerStateChange represents a state change that needs to be sent to the SubmitContainerStateChange API

func (ContainerStateChange) GetEventType added in v1.14.2

func (c ContainerStateChange) GetEventType() statechange.EventType

GetEventType() returns an enum identifying the event type

func (*ContainerStateChange) String added in v1.3.1

func (c *ContainerStateChange) String() string

String returns a human readable string representation of this object

type ContainerStatus

type ContainerStatus int32

ContainerStatus is an enumeration of valid states in the container lifecycle

const (
	// ContainerStatusNone is the zero state of a container; this container has not completed pull
	ContainerStatusNone ContainerStatus = iota
	// ContainerPulled represents a container which has had the image pulled
	ContainerPulled
	// ContainerCreated represents a container that has been created
	ContainerCreated
	// ContainerRunning represents a container that has started
	ContainerRunning
	// ContainerResourcesProvisioned represents a container that has completed provisioning all of its
	// resources. Non-internal containers (containers present in the task definition) transition to
	// this state without doing any additional work. However, containers that are added to a task
	// by the ECS Agent would possibly need to perform additional actions before they can be
	// considered "ready" and contribute to the progress of a task. For example, the "pause" container
	// would be provisioned by invoking CNI plugins
	ContainerResourcesProvisioned
	// ContainerStopped represents a container that has stopped
	ContainerStopped
	// ContainerZombie is an "impossible" state that is used as the maximum
	ContainerZombie
)

func (*ContainerStatus) BackendStatus added in v1.14.5

func (cs *ContainerStatus) BackendStatus(steadyStateStatus ContainerStatus) ContainerStatus

BackendStatus maps the internal container status in the agent to that in the backend

func (ContainerStatus) IsRunning added in v1.14.5

func (cs ContainerStatus) IsRunning() bool

IsRunning returns true if the container status is either RUNNING or RESOURCES_PROVISIONED

func (*ContainerStatus) MarshalJSON

func (cs *ContainerStatus) MarshalJSON() ([]byte, error)

MarshalJSON overrides the logic for JSON-encoding the ContainerStatus type

func (*ContainerStatus) ShouldReportToBackend added in v1.14.5

func (cs *ContainerStatus) ShouldReportToBackend(steadyStateStatus ContainerStatus) bool

ShouldReportToBackend returns true if the container status is recognized as a valid state by ECS. Note that not all container statuses are recognized by ECS or map to ECS states

func (ContainerStatus) String

func (cs ContainerStatus) String() string

String returns a human readable string representation of this object

func (*ContainerStatus) TaskStatus

func (cs *ContainerStatus) TaskStatus(steadyStateStatus ContainerStatus) TaskStatus

TaskStatus maps the container status to the corresponding task status. The transition map is illustrated below.

Container: None -> Pulled -> Created -> Running -> Provisioned -> Stopped -> Zombie

Task : None -> Created -> Running -> Stopped

func (ContainerStatus) Terminal

func (cs ContainerStatus) Terminal() bool

Terminal returns true if the container status is STOPPED

func (*ContainerStatus) UnmarshalJSON

func (cs *ContainerStatus) UnmarshalJSON(b []byte) error

UnmarshalJSON overrides the logic for parsing the JSON-encoded TaskStatus data

type ContainerType added in v1.14.5

type ContainerType int32

ContainerType represents the type of the internal container created

const (
	// ContainerNormal represents the container type for 'Normal' containers
	// These are the ones specified in the task definition via container
	// definitions
	ContainerNormal ContainerType = iota
	// ContainerEmptyHostVolume represents the internal container type
	// for the empty volumes container
	ContainerEmptyHostVolume
	// ContainerCNIPause represents the internal container type for the
	// pause container
	ContainerCNIPause
)

func (*ContainerType) MarshalJSON added in v1.14.5

func (containerType *ContainerType) MarshalJSON() ([]byte, error)

MarshalJSON overrides the logic for JSON-encoding a ContainerType object

func (ContainerType) String added in v1.14.5

func (containerType ContainerType) String() string

String converts the container type enum to a string

func (*ContainerType) UnmarshalJSON added in v1.14.5

func (containerType *ContainerType) UnmarshalJSON(b []byte) error

UnmarshalJSON decodes the container type field in the JSON encoded string into the ContainerType object

type DefaultNamedError added in v1.1.0

type DefaultNamedError struct {
	Err  string `json:"error"`
	Name string `json:"name"`
}

DefaultNamedError is a wrapper type for 'error' which adds an optional name and provides a symmetric marshal/unmarshal

func NewNamedError added in v1.1.0

func NewNamedError(err error) *DefaultNamedError

NewNamedError creates a NamedError.

func (*DefaultNamedError) Error added in v1.1.0

func (err *DefaultNamedError) Error() string

Error implements error

func (*DefaultNamedError) ErrorName added in v1.1.0

func (err *DefaultNamedError) ErrorName() string

ErrorName implements NamedError

type DockerClientConfigError added in v1.1.0

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

func (*DockerClientConfigError) Error added in v1.1.0

func (err *DockerClientConfigError) Error() string

func (*DockerClientConfigError) ErrorName added in v1.1.0

func (err *DockerClientConfigError) ErrorName() string

type DockerConfig added in v1.5.0

type DockerConfig struct {
	Config     *string `json:"config"`
	HostConfig *string `json:"hostConfig"`
	Version    *string `json:"version"`
}

DockerConfig represents additional metadata about a container to run. It's remodeled from the `ecsacs` api model file. Eventually it should not exist once this remodeling is refactored out.

type DockerContainer

type DockerContainer struct {
	DockerID   string `json:"DockerId"`
	DockerName string // needed for linking

	Container *Container
}

DockerContainer is a mapping between containers-as-docker-knows-them and containers-as-we-know-them. This is primarily used in DockerState, but lives here such that tasks and containers know how to convert themselves into Docker's desired config format

func (*DockerContainer) String

func (dc *DockerContainer) String() string

String returns a human readable string representation of DockerContainer

type ECRAuthData added in v1.7.0

type ECRAuthData struct {
	EndpointOverride string `json:"endpointOverride"`
	Region           string `json:"region"`
	RegistryID       string `json:"registryId"`
}

ECRAuthData is the authentication details for ECR specifying the region, registryID, and possible endpoint override

type ECSClient

type ECSClient interface {
	// RegisterContainerInstance calculates the appropriate resources, creates
	// the default cluster if necessary, and returns the registered
	// ContainerInstanceARN if successful. Supplying a non-empty container
	// instance ARN allows a container instance to update its registered
	// resources.
	RegisterContainerInstance(existingContainerInstanceArn string, attributes []*ecs.Attribute) (string, error)
	// SubmitTaskStateChange sends a state change and returns an error
	// indicating if it was submitted
	SubmitTaskStateChange(change TaskStateChange) error
	// SubmitContainerStateChange sends a state change and returns an error
	// indicating if it was submitted
	SubmitContainerStateChange(change ContainerStateChange) error
	// DiscoverPollEndpoint takes a ContainerInstanceARN and returns the
	// endpoint at which this Agent should contact ACS
	DiscoverPollEndpoint(containerInstanceArn string) (string, error)
	// DiscoverTelemetryEndpoint takes a ContainerInstanceARN and returns the
	// endpoint at which this Agent should contact Telemetry Service
	DiscoverTelemetryEndpoint(containerInstanceArn string) (string, error)
}

ECSClient is an interface over the ECSSDK interface which abstracts away some details around constructing the request and reading the response down to the parts the agent cares about. For example, the ever-present 'Cluster' member is abstracted out so that it may be configured once and used throughout transparently.

type ECSSDK added in v1.1.0

ECSSDK is an interface that specifies the subset of the AWS Go SDK's ECS client that the Agent uses. This interface is meant to allow injecting a mock for testing.

type ECSSubmitStateSDK added in v1.4.0

type ECSSubmitStateSDK interface {
	SubmitContainerStateChange(*ecs.SubmitContainerStateChangeInput) (*ecs.SubmitContainerStateChangeOutput, error)
	SubmitTaskStateChange(*ecs.SubmitTaskStateChangeInput) (*ecs.SubmitTaskStateChangeOutput, error)
}

type ENI added in v1.14.5

type ENI struct {
	// ID is the id of eni
	ID string `json:"ec2Id"`
	// IPV4Addresses is the ipv4 address associated with the eni
	IPV4Addresses []*ENIIPV4Address
	// IPV6Addresses is the ipv6 address associated with the eni
	IPV6Addresses []*ENIIPV6Address
	// MacAddress is the mac address of the eni
	MacAddress string
}

ENI contains information of the eni

func ENIFromACS added in v1.14.5

func ENIFromACS(acsenis []*ecsacs.ElasticNetworkInterface) (*ENI, error)

ENIFromACS validates the information from acs message and create the ENI object

type ENIAttachment added in v1.14.5

type ENIAttachment struct {
	// TaskARN is the task identifier from ecs
	TaskARN string `json:"taskArn"`
	// AttachmentARN is the identifier for the eni attachment
	AttachmentARN string `json:"attachmentArn"`
	// AttachStatusSent indicates whether the attached status has been sent to backend
	AttachStatusSent bool `json:"attachSent"`
	// MACAddress is the mac address of eni
	MACAddress string `json:"macAddress"`
	// Status is the status of the eni: none/attached/detached
	Status ENIAttachmentStatus `json:"status"`
	// ExpiresAt is the timestamp past which the ENI Attachment is considered
	// unsuccessful. The SubmitTaskStateChange API, with the attachment information
	// should be invoked before this timestamp.
	ExpiresAt time.Time `json:"expiresAt"`
	// contains filtered or unexported fields
}

ENIAttachment contains the information of the eni attachment

func (*ENIAttachment) IsSent added in v1.14.5

func (eni *ENIAttachment) IsSent() bool

IsSent checks if the eni attached status has been sent

func (*ENIAttachment) SetSentStatus added in v1.14.5

func (eni *ENIAttachment) SetSentStatus()

SetSentStatus marks the eni attached status has been sent

func (*ENIAttachment) StartTimer added in v1.14.5

func (eni *ENIAttachment) StartTimer(timeoutFunc func()) error

StartTimer starts the ack timer to record the expiration of ENI attachment

func (*ENIAttachment) StopAckTimer added in v1.14.5

func (eni *ENIAttachment) StopAckTimer()

StopAckTimer stops the ack timer set on the ENI attachment

func (*ENIAttachment) String added in v1.14.5

func (eni *ENIAttachment) String() string

String returns a string representation of the ENI Attachment

type ENIAttachmentStatus added in v1.14.5

type ENIAttachmentStatus int32

ENIAttachmentStatus is an enumeration type for eni attachment state

const (
	// ENIAttachmentNone is zero state of a task when received attachemessage from acs
	ENIAttachmentNone ENIAttachmentStatus = iota
	// ENIAttached represents that a eni has shown on the host
	ENIAttached
	// ENIDetached represents that a eni has been actually detached from the host
	ENIDetached
)

func (*ENIAttachmentStatus) ShouldSend added in v1.14.5

func (eni *ENIAttachmentStatus) ShouldSend() bool

ShouldSend returns whether the status should be sent to backend

func (*ENIAttachmentStatus) String added in v1.14.5

func (eni *ENIAttachmentStatus) String() string

String return the string value of the eniattachment status

type ENIIPV4Address added in v1.14.5

type ENIIPV4Address struct {
	// Primary indicates whether the ip address is primary
	Primary bool
	// Address is the ipv4 address associated with eni
	Address string
}

ENIIPV4Address is the ipv4 information of the eni

type ENIIPV6Address added in v1.14.5

type ENIIPV6Address struct {
	// Address is the ipv6 address associated with eni
	Address string
}

ENIIPV6Address is the ipv6 information of the eni

type EmptyHostVolume

type EmptyHostVolume struct {
	HostPath string `json:"hostPath"`
}

EmptyHostVolume represents a volume without a specified host path

func (*EmptyHostVolume) SourcePath

func (e *EmptyHostVolume) SourcePath() string

SourcePath returns the generated host path for the volume

type FSHostVolume

type FSHostVolume struct {
	FSSourcePath string `json:"sourcePath"`
}

FSHostVolume is a simple type of HostVolume which references an arbitrary location on the host as the Volume.

func (*FSHostVolume) SourcePath

func (fs *FSHostVolume) SourcePath() string

SourcePath returns the path on the host filesystem that should be mounted

type HostConfigError added in v1.1.0

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

func (*HostConfigError) Error added in v1.1.0

func (err *HostConfigError) Error() string

func (*HostConfigError) ErrorName added in v1.1.0

func (err *HostConfigError) ErrorName() string

type HostVolume

type HostVolume interface {
	SourcePath() string
}

HostVolume is an interface for something that may be used as the host half of a docker volume mount

type MountPoint

type MountPoint struct {
	SourceVolume  string `json:"sourceVolume"`
	ContainerPath string `json:"containerPath"`
	ReadOnly      bool   `json:"readOnly"`
}

MountPoint describes the in-container location of a Volume and references that Volume by name.

type NamedError added in v1.1.0

type NamedError interface {
	error
	ErrorName() string
}

type PortBinding

type PortBinding struct {
	// ContainerPort is the port inside the container
	ContainerPort uint16
	// HostPort is the port exposed on the host
	HostPort uint16
	// BindIP is the IP address to which the port is bound
	BindIP string `json:"BindIp"`
	// Protocol is the protocol of the port
	Protocol TransportProtocol
}

PortBinding represents a port binding for a container

type RegistryAuthenticationData added in v1.7.0

type RegistryAuthenticationData struct {
	Type        string       `json:"type"`
	ECRAuthData *ECRAuthData `json:"ecrAuthData"`
}

RegistryAuthenticationData is the authentication data sent by the ECS backend. Currently, the only supported authentication data is for ECR.

type Task

type Task struct {
	// Arn is the unique identifer for the task
	Arn string
	// Overrides are the overrides applied to a task
	Overrides TaskOverrides `json:"-"`
	// Family is the name of the task definition family
	Family string
	// Version is the version of the task definition
	Version string
	// Containers are the containers for the task
	Containers []*Container
	// Volumes are the volumes for the task
	Volumes []TaskVolume `json:"volumes"`

	// DesiredStatusUnsafe represents the state where the task should go. Generally,
	// the desired status is informed by the ECS backend as a result of either
	// API calls made to ECS or decisions made by the ECS service scheduler.
	// The DesiredStatusUnsafe is almost always either TaskRunning or TaskStopped.
	// NOTE: Do not access DesiredStatusUnsafe directly.  Instead, use `UpdateStatus`,
	// `UpdateDesiredStatus`, `SetDesiredStatus`, and `SetDesiredStatus`.
	// TODO DesiredStatusUnsafe should probably be private with appropriately written
	// setter/getter.  When this is done, we need to ensure that the UnmarshalJSON
	// is handled properly so that the state storage continues to work.
	DesiredStatusUnsafe TaskStatus `json:"DesiredStatus"`

	// KnownStatusUnsafe represents the state where the task is.  This is generally
	// the minimum of equivalent status types for the containers in the task;
	// if one container is at ContainerRunning and another is at ContainerPulled,
	// the task KnownStatusUnsafe would be TaskPulled.
	// NOTE: Do not access KnownStatusUnsafe directly.  Instead, use `UpdateStatus`,
	// and `GetKnownStatus`.
	// TODO KnownStatusUnsafe should probably be private with appropriately written
	// setter/getter.  When this is done, we need to ensure that the UnmarshalJSON
	// is handled properly so that the state storage continues to work.
	KnownStatusUnsafe TaskStatus `json:"KnownStatus"`

	// KnownStatusTimeUnsafe captures the time when the KnownStatusUnsafe was last updated.
	// NOTE: Do not access KnownStatusTime directly, instead use `GetKnownStatusTime`.
	KnownStatusTimeUnsafe time.Time `json:"KnownTime"`

	// SentStatusUnsafe represents the last KnownStatusUnsafe that was sent to the ECS SubmitTaskStateChange API.
	// TODO(samuelkarp) SentStatusUnsafe needs a lock and setters/getters.
	// TODO SentStatusUnsafe should probably be private with appropriately written
	// setter/getter.  When this is done, we need to ensure that the UnmarshalJSON
	// is handled properly so that the state storage continues to work.
	SentStatusUnsafe TaskStatus `json:"SentStatus"`

	StartSequenceNumber int64
	StopSequenceNumber  int64

	// ENI is the elastic network interface specified by this task
	ENI *ENI
	// contains filtered or unexported fields
}

Task is the internal representation of a task in the ECS agent

func RemoveFromTaskArray

func RemoveFromTaskArray(arr []*Task, ndx int) []*Task

RemoveFromTaskArray removes the element at ndx from an array of task pointers, arr. If the ndx is out of bounds, it returns arr unchanged.

func TaskFromACS added in v1.0.0

func TaskFromACS(acsTask *ecsacs.Task, envelope *ecsacs.PayloadMessage) (*Task, error)

TaskFromACS translates ecsacs.Task to api.Task by first marshaling the recieved ecsacs.Task to json and unmrashaling it as api.Task

func (*Task) BuildCNIConfig added in v1.14.5

func (task *Task) BuildCNIConfig() (*ecscni.Config, error)

BuildCNIConfig constructs the cni configuration from eni

func (*Task) ContainerByName

func (task *Task) ContainerByName(name string) (*Container, bool)

ContainerByName returns the *Container for the given name

func (*Task) DockerConfig

func (task *Task) DockerConfig(container *Container) (*docker.Config, *DockerClientConfigError)

DockerConfig converts the given container in this task to the format of GoDockerClient's 'Config' struct

func (*Task) DockerHostConfig

func (task *Task) DockerHostConfig(container *Container, dockerContainerMap map[string]*DockerContainer) (*docker.HostConfig, *HostConfigError)

func (*Task) GetCredentialsID added in v1.14.2

func (task *Task) GetCredentialsID() string

GetCredentialsID gets the credentials ID for the task

func (*Task) GetDesiredStatus added in v1.13.0

func (task *Task) GetDesiredStatus() TaskStatus

GetDesiredStatus gets the desired status of the task

func (*Task) GetKnownStatus added in v1.9.0

func (task *Task) GetKnownStatus() TaskStatus

GetKnownStatus gets the KnownStatus of the task

func (*Task) GetKnownStatusTime added in v1.9.0

func (task *Task) GetKnownStatusTime() time.Time

GetKnownStatusTime gets the KnownStatusTime of the task

func (*Task) GetSentStatus added in v1.14.1

func (task *Task) GetSentStatus() TaskStatus

GetSentStatus safely returns the SentStatus of the task

func (*Task) GetTaskENI added in v1.14.5

func (task *Task) GetTaskENI() *ENI

GetTaskENI returns the eni of task, for now task can only have one enis

func (*Task) HostVolumeByName

func (task *Task) HostVolumeByName(name string) (HostVolume, bool)

HostVolumeByName returns the task Volume for the given a volume name in that task. The second return value indicates the presense of that volume

func (*Task) Overridden

func (task *Task) Overridden() *Task

Overridden returns a copy of the task with all container's overridden and itself overridden as well

func (*Task) PostUnmarshalTask

func (task *Task) PostUnmarshalTask(cfg *config.Config, credentialsManager credentials.Manager)

PostUnmarshalTask is run after a task has been unmarshalled, but before it has been run. It is possible it will be subsequently called after that and should be able to handle such an occurrence appropriately (e.g. behave idempotently).

func (*Task) SetCredentialsID added in v1.14.2

func (task *Task) SetCredentialsID(id string)

SetCredentialsID sets the credentials ID for the task

func (*Task) SetDesiredStatus added in v1.13.0

func (task *Task) SetDesiredStatus(status TaskStatus)

SetDesiredStatus sets the desired status of the task

func (*Task) SetKnownStatus added in v1.1.0

func (task *Task) SetKnownStatus(status TaskStatus)

SetKnownStatus sets the known status of the task

func (*Task) SetSentStatus added in v1.14.1

func (task *Task) SetSentStatus(status TaskStatus)

SetSentStatus safely sets the SentStatus of the task

func (*Task) SetTaskENI added in v1.14.5

func (task *Task) SetTaskENI(eni *ENI)

SetTaskENI sets the eni information of the task

func (*Task) String

func (t *Task) String() string

String returns a human readable string representation of this object

func (*Task) UpdateDesiredStatus added in v1.1.0

func (task *Task) UpdateDesiredStatus()

UpdateDesiredStatus sets the known status of the task

func (*Task) UpdateMountPoints

func (task *Task) UpdateMountPoints(cont *Container, vols map[string]string)

UpdateMountPoints updates the mount points of volumes that were created without specifying a host path. This is used as part of the empty host volume feature.

func (*Task) UpdateStatus added in v1.1.0

func (task *Task) UpdateStatus() bool

UpdateStatus updates a task's known and desired statuses to be compatible with all of its containers It will return a bool indicating if there was a change

type TaskOverrides

type TaskOverrides struct{}

TaskOverrides are the overrides applied to a task

type TaskStateChange added in v1.1.0

type TaskStateChange struct {
	// Attachment is the eni attachment object to send
	Attachment *ENIAttachment
	// TaskArn is the unique identifier for the task
	TaskARN string
	// Status is the status to send
	Status TaskStatus
	// Reason may contain details of why the task stopped
	Reason string
	// Containers holds the events generated by containers owned by this task
	Containers []ContainerStateChange

	// Task is a pointer to the task involved in the state change that gives the event handler a hook into storing
	// what status was sent.  This is used to ensure the same event is handled only once.
	Task *Task
}

TaskStateChange represents a state change that needs to be sent to the SubmitTaskStateChange API

func (TaskStateChange) GetEventType added in v1.14.2

func (t TaskStateChange) GetEventType() statechange.EventType

GetEventType() returns an enum identifying the event type

func (*TaskStateChange) String added in v1.3.1

func (t *TaskStateChange) String() string

String returns a human readable string representation of this object

type TaskStatus

type TaskStatus int32

TaskStatus is an enumeration of valid states in the task lifecycle

const (
	// TaskStatusNone is the zero state of a task; this task has been received but no further progress has completed
	TaskStatusNone TaskStatus = iota
	// TaskPulled represents a task which has had all its container images pulled, but not all have yet progressed passed pull
	TaskPulled
	// TaskCreated represents a task which has had all its containers created
	TaskCreated
	// TaskRunning represents a task which has had all its containers started
	TaskRunning
	// TaskStopped represents a task in which all containers are stopped
	TaskStopped
	// TaskZombie is an "impossible" state that is used as the maximum
	TaskZombie
)

func (*TaskStatus) BackendRecognized added in v1.1.0

func (ts *TaskStatus) BackendRecognized() bool

BackendRecognized returns true if the task status is recognized as a valid state by ECS. Note that not all task statuses are recognized by ECS or map to ECS states

func (*TaskStatus) BackendStatus added in v1.0.0

func (ts *TaskStatus) BackendStatus() string

BackendStatus maps the internal task status in the agent to that in the backend

func (*TaskStatus) ContainerStatus

func (ts *TaskStatus) ContainerStatus(steadyState ContainerStatus) ContainerStatus

ContainerStatus maps the task status to the corresponding container status

func (*TaskStatus) MarshalJSON

func (ts *TaskStatus) MarshalJSON() ([]byte, error)

MarshalJSON overrides the logic for JSON-encoding the TaskStatus type

func (TaskStatus) String

func (ts TaskStatus) String() string

String returns a human readable string representation of this object

func (TaskStatus) Terminal

func (ts TaskStatus) Terminal() bool

Terminal returns true if the Task status is STOPPED

func (*TaskStatus) UnmarshalJSON

func (ts *TaskStatus) UnmarshalJSON(b []byte) error

UnmarshalJSON overrides the logic for parsing the JSON-encoded TaskStatus data

type TaskVolume

type TaskVolume struct {
	Name   string `json:"name"`
	Volume HostVolume
}

TaskVolume is a definition of all the volumes available for containers to reference within a task. It must be named.

func (*TaskVolume) MarshalJSON

func (tv *TaskVolume) MarshalJSON() ([]byte, error)

MarshalJSON overrides the logic for JSON-encoding a TaskVolume object

func (*TaskVolume) UnmarshalJSON

func (tv *TaskVolume) UnmarshalJSON(b []byte) error

UnmarshalJSON for TaskVolume determines the name and volume type, and unmarshals it into the appropriate HostVolume fulfilling interfaces

type TransitionDependencySet added in v1.14.5

type TransitionDependencySet struct {
	// ContainerDependencies is the set of containers on which a transition is
	// dependent.
	ContainerDependencies []ContainerDependency `json:"ContainerDependencies"`
}

TransitionDependencySet contains dependencies that impact transitions of containers.

type TransportProtocol added in v1.2.0

type TransportProtocol int32

TransportProtocol is an enumeration of valid transport protocols

const (
	// TransportProtocolTCP represents TCP
	TransportProtocolTCP TransportProtocol = iota
	// TransportProtocolUDP represents UDP
	TransportProtocolUDP
)

func NewTransportProtocol added in v1.2.0

func NewTransportProtocol(protocol string) (TransportProtocol, error)

NewTransportProtocol returns a TransportProtocol from a string in the task

func (*TransportProtocol) MarshalJSON added in v1.2.0

func (tp *TransportProtocol) MarshalJSON() ([]byte, error)

MarshalJSON overrides the logic for JSON-encoding the TransportProtocol type

func (*TransportProtocol) String added in v1.2.0

func (tp *TransportProtocol) String() string

String converts TransportProtocol to a string

func (*TransportProtocol) UnmarshalJSON added in v1.2.0

func (tp *TransportProtocol) UnmarshalJSON(b []byte) error

UnmarshalJSON for TransportProtocol determines whether to use TCP or UDP, setting TCP as the zero-value but treating other unrecognized values as errors

type VolumeFrom

type VolumeFrom struct {
	SourceContainer string `json:"sourceContainer"`
	ReadOnly        bool   `json:"readOnly"`
}

VolumeFrom is a volume which references another container as its source.

Notes

Bugs

  • On Windows, volumes with names that differ only by case will collide

Directories

Path Synopsis
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