Documentation ¶
Index ¶
- Constants
- type Association
- type EncodedString
- type PlatformFields
- type Task
- func (task *Task) AddFirelensContainerBindMounts(firelensConfig *apicontainer.FirelensConfig, ...) *apierrors.HostConfigError
- func (task *Task) AddResource(resourceType string, resource taskresource.TaskResource)
- func (task *Task) AddTaskENI(eni *apieni.ENI)
- func (task *Task) ApplyExecutionRoleLogsAuth(hostConfig *dockercontainer.HostConfig, credentialsManager credentials.Manager) *apierrors.HostConfigError
- func (task *Task) AssociationByTypeAndName(associationType, associationName string) (*Association, bool)
- func (task *Task) AssociationsByTypeAndContainer(associationType, containerName string) []string
- func (task *Task) BuildCNIConfig(includeIPAMConfig bool, cniConfig *ecscni.Config) (*ecscni.Config, error)
- func (task *Task) BuildCgroupRoot() (string, error)
- func (task *Task) BuildLinuxResourceSpec(cGroupCPUPeriod time.Duration) (specs.LinuxResources, error)
- func (task *Task) ContainerByName(name string) (*apicontainer.Container, bool)
- func (task *Task) DockerConfig(container *apicontainer.Container, apiVersion dockerclient.DockerVersion) (*dockercontainer.Config, *apierrors.DockerClientConfigError)
- func (task *Task) DockerHostConfig(container *apicontainer.Container, ...) (*dockercontainer.HostConfig, *apierrors.HostConfigError)
- func (task *Task) GetAppMesh() *apiappmesh.AppMesh
- func (task *Task) GetContainerIndex(containerName string) int
- func (task *Task) GetCredentialSpecResource() ([]taskresource.TaskResource, bool)
- func (task *Task) GetCredentialsID() string
- func (task *Task) GetDesiredStatus() apitaskstatus.TaskStatus
- func (task *Task) GetExecutionCredentialsID() string
- func (task *Task) GetExecutionStoppedAt() time.Time
- func (task *Task) GetFirelensContainer() *apicontainer.Container
- func (task *Task) GetID() (string, error)
- func (task *Task) GetKnownStatus() apitaskstatus.TaskStatus
- func (task *Task) GetKnownStatusTime() time.Time
- func (task *Task) GetPrimaryENI() *apieni.ENI
- func (task *Task) GetPullStartedAt() time.Time
- func (task *Task) GetPullStoppedAt() time.Time
- func (task *Task) GetResources() []taskresource.TaskResource
- func (task *Task) GetSentStatus() apitaskstatus.TaskStatus
- func (task *Task) GetStopSequenceNumber() int64
- func (task *Task) GetTaskENIs() []*apieni.ENI
- func (task *Task) GetTerminalReason() string
- func (task *Task) HostVolumeByName(name string) (taskresourcevolume.Volume, bool)
- func (task *Task) InitializeResources(resourceFields *taskresource.ResourceFields)
- func (task *Task) IsNetworkModeAWSVPC() bool
- func (task *Task) PopulateASMAuthData(container *apicontainer.Container) error
- func (task *Task) PopulateSecretLogOptionsToFirelensContainer(firelensContainer *apicontainer.Container) *apierrors.DockerClientConfigError
- func (task *Task) PopulateSecrets(hostConfig *dockercontainer.HostConfig, container *apicontainer.Container) *apierrors.DockerClientConfigError
- func (task *Task) PostUnmarshalTask(cfg *config.Config, credentialsManager credentials.Manager, ...) error
- func (task *Task) RecordExecutionStoppedAt(container *apicontainer.Container)
- func (task *Task) SetAppMesh(appMesh *apiappmesh.AppMesh)
- func (task *Task) SetCredentialsID(id string)
- func (task *Task) SetDesiredStatus(status apitaskstatus.TaskStatus)
- func (task *Task) SetExecutionRoleCredentialsID(id string)
- func (task *Task) SetExecutionStoppedAt(timestamp time.Time) bool
- func (task *Task) SetKnownStatus(status apitaskstatus.TaskStatus)
- func (task *Task) SetPullStartedAt(timestamp time.Time) bool
- func (task *Task) SetPullStoppedAt(timestamp time.Time)
- func (task *Task) SetSentStatus(status apitaskstatus.TaskStatus)
- func (task *Task) SetStopSequenceNumber(seqnum int64)
- func (task *Task) SetTerminalReason(reason string)
- func (task *Task) String() string
- func (task *Task) UpdateDesiredStatus()
- func (task *Task) UpdateMountPoints(cont *apicontainer.Container, vols []types.MountPoint)
- func (task *Task) UpdateStatus() bool
- type TaskENIs
- type TaskOverrides
- type TaskVolume
- Bugs
Constants ¶
const ( // NetworkPauseContainerName is the internal name for the pause container NetworkPauseContainerName = "~internal~ecs~pause" // NamespacePauseContainerName is the internal name for the IPC resource namespace and/or // PID namespace sharing pause container NamespacePauseContainerName = "~internal~ecs~pause~namespace" NvidiaVisibleDevicesEnvVar = "NVIDIA_VISIBLE_DEVICES" GPUAssociationType = "gpu" ContainerOrderingCreateCondition = "CREATE" ContainerOrderingStartCondition = "START" // specifies bridge type mode for a task BridgeNetworkMode = "bridge" // specifies awsvpc type mode for a task AWSVPCNetworkMode = "awsvpc" )
const ( HostVolumeType = "host" DockerVolumeType = "docker" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Association ¶ added in v1.25.0
type Association struct { // Containers are the container names that can use this association. Containers []string `json:"containers"` // Content describes this association. Content EncodedString `json:"content"` // Name is a unique identifier of the association within a task. Name string `json:"name"` // Type specifies the type of this association. Type string `json:"type"` }
Association is a definition of a device (or other potential things) that is associated with a task.
type EncodedString ¶ added in v1.25.0
type EncodedString struct { // Encoding is the encoding type of the value. Encoding string `json:"encoding"` // Value is the content of the encoded string. Value string `json:"value"` }
EncodedString is used to describe an association, the consumer of the association data should be responsible to decode it. We don't model it in Agent, or check the value of the encoded string, we just pass whatever we get from ACS, because we don't want Agent to be coupled with a specific association.
type PlatformFields ¶ added in v1.20.2
type PlatformFields struct{}
PlatformFields consists of fields specific to Linux for a task
type Task ¶
type Task struct { // Arn is the unique identifier 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 []*apicontainer.Container // Associations are the available associations for the task. Associations []Association `json:"associations"` // ResourcesMapUnsafe is the map of resource type to corresponding resources ResourcesMapUnsafe resourcetype.ResourcesMap `json:"resources"` // Volumes are the volumes for the task Volumes []TaskVolume `json:"volumes"` // CPU is a task-level limit for compute resources. A value of 1 means that // the task may access 100% of 1 vCPU on the instance CPU float64 `json:"Cpu,omitempty"` // Memory is a task-level limit for memory resources in bytes Memory int64 `json:"Memory,omitempty"` // 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 apitaskstatus.TaskRunning or apitaskstatus.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 apitaskstatus.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 apitaskstatus.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"` // PullStartedAtUnsafe is the timestamp when the task start pulling the first container, // it won't be set if the pull never happens PullStartedAtUnsafe time.Time `json:"PullStartedAt"` // PullStoppedAtUnsafe is the timestamp when the task finished pulling the last container, // it won't be set if the pull never happens PullStoppedAtUnsafe time.Time `json:"PullStoppedAt"` // ExecutionStoppedAtUnsafe is the timestamp when the task desired status moved to stopped, // which is when the any of the essential containers stopped ExecutionStoppedAtUnsafe time.Time `json:"ExecutionStoppedAt"` // 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 apitaskstatus.TaskStatus `json:"SentStatus"` StartSequenceNumber int64 StopSequenceNumber int64 // ExecutionCredentialsID is the ID of credentials that are used by agent to // perform some action at the task level, such as pulling image from ECR ExecutionCredentialsID string `json:"executionCredentialsID"` // ENIs is the list of Elastic Network Interfaces assigned to this task. The // TaskENIs type is helpful when decoding state files which might have stored // ENIs as a single ENI object instead of a list. ENIs TaskENIs `json:"ENI"` // AppMesh is the service mesh specified by the task AppMesh *apiappmesh.AppMesh // MemoryCPULimitsEnabled to determine if task supports CPU, memory limits MemoryCPULimitsEnabled bool `json:"MemoryCPULimitsEnabled,omitempty"` // PlatformFields consists of fields specific to linux/windows for a task PlatformFields PlatformFields `json:"PlatformFields,omitempty"` // PIDMode is used to determine how PID namespaces are organized between // containers of the Task PIDMode string `json:"PidMode,omitempty"` // IPCMode is used to determine how IPC resources should be shared among // containers of the Task IPCMode string `json:"IpcMode,omitempty"` // NvidiaRuntime is the runtime to pass Nvidia GPU devices to containers NvidiaRuntime string `json:"NvidiaRuntime,omitempty"` // contains filtered or unexported fields }
Task is the internal representation of a task in the ECS agent
func RemoveFromTaskArray ¶
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 ¶
TaskFromACS translates ecsacs.Task to apitask.Task by first marshaling the received ecsacs.Task to json and unmarshaling it as apitask.Task
func (*Task) AddFirelensContainerBindMounts ¶ added in v1.30.0
func (task *Task) AddFirelensContainerBindMounts(firelensConfig *apicontainer.FirelensConfig, hostConfig *dockercontainer.HostConfig, config *config.Config) *apierrors.HostConfigError
AddFirelensContainerBindMounts adds config file bind mount and socket directory bind mount to the firelens container's host config.
func (*Task) AddResource ¶
func (task *Task) AddResource(resourceType string, resource taskresource.TaskResource)
AddResource adds a resource to ResourcesMap
func (*Task) AddTaskENI ¶ added in v1.31.0
AddTaskENI adds ENI information to the task.
func (*Task) ApplyExecutionRoleLogsAuth ¶
func (task *Task) ApplyExecutionRoleLogsAuth(hostConfig *dockercontainer.HostConfig, credentialsManager credentials.Manager) *apierrors.HostConfigError
ApplyExecutionRoleLogsAuth will check whether the task has execution role credentials, and add the genereated credentials endpoint to the associated HostConfig
func (*Task) AssociationByTypeAndName ¶ added in v1.25.0
func (task *Task) AssociationByTypeAndName(associationType, associationName string) (*Association, bool)
AssociationByTypeAndName gets an association of a certain type and name
func (*Task) AssociationsByTypeAndContainer ¶ added in v1.25.0
AssociationByTypeAndContainer gets a list of names of all the associations associated with a container and of a certain type
func (*Task) BuildCNIConfig ¶
func (task *Task) BuildCNIConfig(includeIPAMConfig bool, cniConfig *ecscni.Config) (*ecscni.Config, error)
BuildCNIConfig builds a list of CNI network configurations for the task. If includeIPAMConfig is set to true, the list also includes the bridge IPAM configuration.
func (*Task) BuildCgroupRoot ¶
BuildCgroupRoot helps build the task cgroup prefix Example: /ecs/task-id
func (*Task) BuildLinuxResourceSpec ¶
func (task *Task) BuildLinuxResourceSpec(cGroupCPUPeriod time.Duration) (specs.LinuxResources, error)
BuildLinuxResourceSpec returns a linuxResources object for the task cgroup
func (*Task) ContainerByName ¶
func (task *Task) ContainerByName(name string) (*apicontainer.Container, bool)
ContainerByName returns the *Container for the given name
func (*Task) DockerConfig ¶
func (task *Task) DockerConfig(container *apicontainer.Container, apiVersion dockerclient.DockerVersion) (*dockercontainer.Config, *apierrors.DockerClientConfigError)
DockerConfig converts the given container in this task to the format of the Docker SDK 'Config' struct
func (*Task) DockerHostConfig ¶
func (task *Task) DockerHostConfig(container *apicontainer.Container, dockerContainerMap map[string]*apicontainer.DockerContainer, apiVersion dockerclient.DockerVersion) (*dockercontainer.HostConfig, *apierrors.HostConfigError)
DockerHostConfig construct the configuration recognized by docker
func (*Task) GetAppMesh ¶ added in v1.26.0
func (task *Task) GetAppMesh() *apiappmesh.AppMesh
GetAppMesh returns the app mesh config of the task
func (*Task) GetContainerIndex ¶ added in v1.30.0
GetContainerIndex returns the index of the container in the container list. This doesn't count internal container.
func (*Task) GetCredentialSpecResource ¶ added in v1.34.0
func (task *Task) GetCredentialSpecResource() ([]taskresource.TaskResource, bool)
GetCredentialSpecResource retrieves credentialspec resource from resource map
func (*Task) GetCredentialsID ¶
GetCredentialsID gets the credentials ID for the task
func (*Task) GetDesiredStatus ¶
func (task *Task) GetDesiredStatus() apitaskstatus.TaskStatus
GetDesiredStatus gets the desired status of the task
func (*Task) GetExecutionCredentialsID ¶
GetExecutionCredentialsID gets the credentials ID for the task
func (*Task) GetExecutionStoppedAt ¶
GetExecutionStoppedAt returns the task executionStoppedAt timestamp
func (*Task) GetFirelensContainer ¶ added in v1.31.0
func (task *Task) GetFirelensContainer() *apicontainer.Container
GetFirelensContainer returns the firelens container in the task, if there is one.
func (*Task) GetID ¶
GetID is used to retrieve the taskID from taskARN Reference: http://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html#arn-syntax-ecs
func (*Task) GetKnownStatus ¶
func (task *Task) GetKnownStatus() apitaskstatus.TaskStatus
GetKnownStatus gets the KnownStatus of the task
func (*Task) GetKnownStatusTime ¶
GetKnownStatusTime gets the KnownStatusTime of the task
func (*Task) GetPrimaryENI ¶ added in v1.31.0
GetPrimaryENI returns the primary ENI of the task. Since ACS can potentially send multiple ENIs to the agent, the first ENI in the list is considered as the primary ENI.
func (*Task) GetPullStartedAt ¶
GetPullStartedAt returns the PullStartedAt timestamp
func (*Task) GetPullStoppedAt ¶
GetPullStoppedAt returns the PullStoppedAt timestamp
func (*Task) GetResources ¶
func (task *Task) GetResources() []taskresource.TaskResource
GetResources returns the list of task resources from ResourcesMap
func (*Task) GetSentStatus ¶
func (task *Task) GetSentStatus() apitaskstatus.TaskStatus
GetSentStatus safely returns the SentStatus of the task
func (*Task) GetStopSequenceNumber ¶
GetStopSequenceNumber returns the stop sequence number of a task
func (*Task) GetTaskENIs ¶ added in v1.31.0
GetTaskENIs returns the list of ENIs for the task.
func (*Task) GetTerminalReason ¶
GetTerminalReason retrieves the terminalReason string
func (*Task) HostVolumeByName ¶
func (task *Task) HostVolumeByName(name string) (taskresourcevolume.Volume, bool)
HostVolumeByName returns the task Volume for the given a volume name in that task. The second return value indicates the presence of that volume
func (*Task) InitializeResources ¶
func (task *Task) InitializeResources(resourceFields *taskresource.ResourceFields)
InitializeResources initializes the required field in the task on agent restart Some of the fields in task isn't saved in the agent state file, agent needs to initialize these fields before processing the task, eg: docker client in resource
func (*Task) IsNetworkModeAWSVPC ¶ added in v1.31.0
IsNetworkModeAWSVPC checks if the task is configured to use the AWSVPC task networking feature.
func (*Task) PopulateASMAuthData ¶
func (task *Task) PopulateASMAuthData(container *apicontainer.Container) error
PopulateASMAuthData sets docker auth credentials for a container
func (*Task) PopulateSecretLogOptionsToFirelensContainer ¶ added in v1.30.0
func (task *Task) PopulateSecretLogOptionsToFirelensContainer(firelensContainer *apicontainer.Container) *apierrors.DockerClientConfigError
PopulateSecretLogOptionsToFirelensContainer collects secret log option values for awsfirelens log driver from task resource and specified then as envs of firelens container. Firelens container will use the envs to resolve config file variables constructed for secret log options when loading the config file.
func (*Task) PopulateSecrets ¶ added in v1.27.0
func (task *Task) PopulateSecrets(hostConfig *dockercontainer.HostConfig, container *apicontainer.Container) *apierrors.DockerClientConfigError
PopulateSecrets appends secrets to container's env var map and hostconfig section
func (*Task) PostUnmarshalTask ¶
func (task *Task) PostUnmarshalTask(cfg *config.Config, credentialsManager credentials.Manager, resourceFields *taskresource.ResourceFields, dockerClient dockerapi.DockerClient, ctx context.Context) error
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) RecordExecutionStoppedAt ¶
func (task *Task) RecordExecutionStoppedAt(container *apicontainer.Container)
RecordExecutionStoppedAt checks if this is an essential container stopped and set the task executionStoppedAt timestamps
func (*Task) SetAppMesh ¶ added in v1.26.0
func (task *Task) SetAppMesh(appMesh *apiappmesh.AppMesh)
SetAppMesh sets the app mesh config of the task
func (*Task) SetCredentialsID ¶
SetCredentialsID sets the credentials ID for the task
func (*Task) SetDesiredStatus ¶
func (task *Task) SetDesiredStatus(status apitaskstatus.TaskStatus)
SetDesiredStatus sets the desired status of the task
func (*Task) SetExecutionRoleCredentialsID ¶
SetExecutionRoleCredentialsID sets the ID for the task execution role credentials
func (*Task) SetExecutionStoppedAt ¶
SetExecutionStoppedAt sets the ExecutionStoppedAt timestamp of the task
func (*Task) SetKnownStatus ¶
func (task *Task) SetKnownStatus(status apitaskstatus.TaskStatus)
SetKnownStatus sets the known status of the task
func (*Task) SetPullStartedAt ¶
SetPullStartedAt sets the task pullstartedat timestamp and returns whether this field was updated or not
func (*Task) SetPullStoppedAt ¶
SetPullStoppedAt sets the task pullstoppedat timestamp
func (*Task) SetSentStatus ¶
func (task *Task) SetSentStatus(status apitaskstatus.TaskStatus)
SetSentStatus safely sets the SentStatus of the task
func (*Task) SetStopSequenceNumber ¶
SetStopSequenceNumber sets the stop seqence number of a task
func (*Task) SetTerminalReason ¶
SetTerminalReason sets the terminalReason string and this can only be set once per the task's lifecycle. This field does not accept updates.
func (*Task) UpdateDesiredStatus ¶
func (task *Task) UpdateDesiredStatus()
UpdateDesiredStatus sets the known status of the task
func (*Task) UpdateMountPoints ¶
func (task *Task) UpdateMountPoints(cont *apicontainer.Container, vols []types.MountPoint)
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 ¶
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 TaskENIs ¶ added in v1.31.0
TaskENIs type enumerates the list of ENI objects as a type. It is used for implementing a custom unmarshaler. The unmarshaler is capable of unmarshaling both a list of ENI objects into the TaskENIs type (the new scheme) or a single ENI object into the TaskENIs type (the old scheme before this object was introduced).
The 'task' package is deemed to be a better home for this than the 'eni' package since this is only required for unmarshaling 'Task' object. None of the functionality/types in the 'eni' package themselves have any dependencies on this type.
func (*TaskENIs) UnmarshalJSON ¶ added in v1.31.0
type TaskVolume ¶
type TaskVolume struct { Type string `json:"type"` Name string `json:"name"` Volume taskresourcevolume.Volume }
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
Notes ¶
Bugs ¶
On Windows, volumes with names that differ only by case will collide