task

package
v1.30.0-coveo.0 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2019 License: Apache-2.0 Imports: 40 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"
)
View Source
const (
	HostVolumeType   = "host"
	DockerVolumeType = "docker"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Association

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

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

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

	// ENI is the elastic network interface specified by this task
	ENI *apieni.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

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

func (task *Task) AddFirelensContainerBindMounts(firelensConfigType string, 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) 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

func (task *Task) AssociationByTypeAndName(associationType, associationName string) (*Association, bool)

AssociationByTypeAndName gets an association of a certain type and name

func (*Task) AssociationsByTypeAndContainer

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() (*ecscni.Config, error)

BuildCNIConfig constructs the cni configuration from eni

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) (*dockercontainer.HostConfig, *apierrors.HostConfigError)

DockerHostConfig construct the configuration recognized by docker

func (*Task) GetAppMesh

func (task *Task) GetAppMesh() *apiappmesh.AppMesh

GetAppMesh returns the app mesh config of the task

func (*Task) GetContainerIndex

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

func (task *Task) GetCredentialsID() string

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

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

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

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

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

func (task *Task) PopulateASMAuthData(container *apicontainer.Container) error

PopulateASMAuthData sets docker auth credentials for a container

func (*Task) PopulateSecretLogOptionsToFirelensContainer

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

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

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

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

SetTaskENI sets the eni information of the 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 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