task

package
v1.49.0 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2021 License: Apache-2.0 Imports: 44 Imported by: 0

Documentation

Index

Constants

View Source
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"
)
View Source
const (
	HostVolumeType                 = "host"
	DockerVolumeType               = "docker"
	EFSVolumeType                  = "efs"
	FSxWindowsFileServerVolumeType = "fsxWindowsFileServer"
)

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"`

	// LocalIPAddressUnsafe stores the local IP address allocated to the bridge that connects the task network
	// namespace and the host network namespace, for tasks in awsvpc network mode (tasks in other network mode won't
	// have a value for this). This field should be accessed via GetLocalIPAddress and SetLocalIPAddress.
	LocalIPAddressUnsafe string `json:"LocalIPAddress,omitempty"`

	// LaunchType is the launch type of this task.
	LaunchType string `json:"LaunchType,omitempty"`
	// 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

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

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

func (task *Task) AddTaskENI(eni *apieni.ENI)

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

func (task *Task) AssociationsByTypeAndContainer(associationType, containerName string) []string

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

func (task *Task) BuildCgroupRoot() (string, error)

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

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, cfg *config.Config) (*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

func (task *Task) GetContainerIndex(containerName string) int

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

func (task *Task) GetCredentialsID() string

GetCredentialsID gets the credentials ID for the task

func (*Task) GetCredentialsRelativeURI added in v1.38.0

func (task *Task) GetCredentialsRelativeURI() string

GetCredentialsRelativeURI returns the credentials relative uri for the task

func (*Task) GetDesiredStatus

func (task *Task) GetDesiredStatus() apitaskstatus.TaskStatus

GetDesiredStatus gets the desired status of the task

func (*Task) GetExecutionCredentialsID

func (task *Task) GetExecutionCredentialsID() string

GetExecutionCredentialsID gets the credentials ID for the task

func (*Task) GetExecutionStoppedAt

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

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

func (task *Task) GetID() (string, error)

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

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

GetKnownStatusTime gets the KnownStatusTime of the task

func (*Task) GetLocalIPAddress added in v1.44.0

func (task *Task) GetLocalIPAddress() string

GetLocalIPAddress returns the local IP address of the task.

func (*Task) GetPrimaryENI added in v1.31.0

func (task *Task) GetPrimaryENI() *apieni.ENI

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

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

GetPullStartedAt returns the PullStartedAt timestamp

func (*Task) GetPullStoppedAt

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

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

func (task *Task) GetStopSequenceNumber() int64

GetStopSequenceNumber returns the stop sequence number of a task

func (*Task) GetTaskENIs added in v1.31.0

func (task *Task) GetTaskENIs() []*apieni.ENI

GetTaskENIs returns the list of ENIs for the task.

func (*Task) GetTerminalReason

func (task *Task) GetTerminalReason() string

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

func (task *Task) IsNetworkModeAWSVPC() bool

IsNetworkModeAWSVPC checks if the task is configured to use the AWSVPC task networking feature.

func (*Task) MarshalJSON added in v1.35.0

func (t *Task) MarshalJSON() ([]byte, error)

MarshalJSON wraps Go's marshalling logic with a necessary read lock.

func (*Task) MergeEnvVarsFromEnvfiles added in v1.39.0

func (task *Task) MergeEnvVarsFromEnvfiles(container *apicontainer.Container) *apierrors.ResourceInitError

MergeEnvVarsFromEnvfiles should be called when creating a container - this method reads the environment variables specified in the environment files that was downloaded to disk and merges it with existing environment variables

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

func (task *Task) SetCredentialsID(id string)

SetCredentialsID sets the credentials ID for the task

func (*Task) SetCredentialsRelativeURI added in v1.38.0

func (task *Task) SetCredentialsRelativeURI(uri string)

SetCredentialsRelativeURI sets the credentials relative uri for the task

func (*Task) SetDesiredStatus

func (task *Task) SetDesiredStatus(status apitaskstatus.TaskStatus)

SetDesiredStatus sets the desired status of the task

func (*Task) SetExecutionRoleCredentialsID

func (task *Task) SetExecutionRoleCredentialsID(id string)

SetExecutionRoleCredentialsID sets the ID for the task execution role credentials

func (*Task) SetExecutionStoppedAt

func (task *Task) SetExecutionStoppedAt(timestamp time.Time) bool

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) SetLocalIPAddress added in v1.44.0

func (task *Task) SetLocalIPAddress(addr string)

SetLocalIPAddress sets the local IP address of the task.

func (*Task) SetPausePIDInVolumeResources added in v1.38.0

func (task *Task) SetPausePIDInVolumeResources(pid string)

SetPausePIDInVolumeResources sets the pause container pid field in each volume resource.

func (*Task) SetPullStartedAt

func (task *Task) SetPullStartedAt(timestamp time.Time) bool

SetPullStartedAt sets the task pullstartedat timestamp and returns whether this field was updated or not

func (*Task) SetPullStoppedAt

func (task *Task) SetPullStoppedAt(timestamp time.Time)

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

func (task *Task) SetStopSequenceNumber(seqnum int64)

SetStopSequenceNumber sets the stop seqence number of a task

func (*Task) SetTerminalReason

func (task *Task) SetTerminalReason(reason string)

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) String

func (task *Task) String() string

String returns a human readable string representation of this object

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

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 TaskENIs added in v1.31.0

type TaskENIs []*apieni.ENI

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

func (taskENIs *TaskENIs) UnmarshalJSON(b []byte) error

type TaskOverrides

type TaskOverrides struct{}

TaskOverrides are the overrides applied to a task

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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