Documentation ¶
Overview ¶
Package pod models a single pod (a group of containers), which can run container tasks.
Index ¶
- Constants
- Variables
- func ByExternalID(id string) bson.M
- func ByID(id string) bson.M
- func Count(q db.Q) (int, error)
- func CountByInitializing() (int, error)
- func UpdateOne(query interface{}, update interface{}) error
- func UpdateOneStatus(id string, current, updated Status, ts time.Time, reason string) error
- type Arch
- type ContainerResourceInfo
- type OS
- type Pod
- func Find(q db.Q) ([]Pod, error)
- func FindByInitializing() ([]Pod, error)
- func FindByLastCommunicatedBefore(ts time.Time) ([]Pod, error)
- func FindByNeedsTermination() ([]Pod, error)
- func FindIntentByFamily(family string) ([]Pod, error)
- func FindOne(q db.Q) (*Pod, error)
- func FindOneByExternalID(id string) (*Pod, error)
- func FindOneByID(id string) (*Pod, error)
- func NewTaskIntentPod(ecsConf evergreen.ECSConfig, opts TaskIntentPodOptions) (*Pod, error)
- func (p *Pod) ClearRunningTask() error
- func (p *Pod) GetSecret() (*Secret, error)
- func (p *Pod) Insert() error
- func (p *Pod) InsertWithContext(ctx context.Context, env evergreen.Environment) error
- func (p *Pod) Remove() error
- func (p *Pod) SetRunningTask(ctx context.Context, env evergreen.Environment, taskID string, ...) error
- func (p *Pod) UpdateAgentStartTime() error
- func (p *Pod) UpdateLastCommunicated() error
- func (p *Pod) UpdateResources(info ResourceInfo) error
- func (p *Pod) UpdateStatus(s Status, reason string) error
- type ResourceInfo
- type Secret
- type Status
- type StatusCount
- type TaskContainerCreationOptions
- type TaskIntentPodOptions
- type TaskRuntimeInfo
- type TimeInfo
- type Type
- type WindowsVersion
Constants ¶
const ( // PodIDEnvVar is the name of the environment variable containing the pod // ID. PodIDEnvVar = "POD_ID" // PodIDEnvVar is the name of the environment variable containing the shared // secret between the server and the pod. PodSecretEnvVar = "POD_SECRET" )
const (
Collection = "pods"
)
Variables ¶
var ( IDKey = bsonutil.MustHaveTag(Pod{}, "ID") TypeKey = bsonutil.MustHaveTag(Pod{}, "Type") StatusKey = bsonutil.MustHaveTag(Pod{}, "Status") TaskContainerCreationOptsKey = bsonutil.MustHaveTag(Pod{}, "TaskContainerCreationOpts") FamilyKey = bsonutil.MustHaveTag(Pod{}, "Family") TimeInfoKey = bsonutil.MustHaveTag(Pod{}, "TimeInfo") ResourcesKey = bsonutil.MustHaveTag(Pod{}, "Resources") TaskRuntimeInfoKey = bsonutil.MustHaveTag(Pod{}, "TaskRuntimeInfo") TaskContainerCreationOptsImageKey = bsonutil.MustHaveTag(TaskContainerCreationOptions{}, "Image") TaskContainerCreationOptsMemoryMBKey = bsonutil.MustHaveTag(TaskContainerCreationOptions{}, "MemoryMB") TaskContainerCreationOptsCPUKey = bsonutil.MustHaveTag(TaskContainerCreationOptions{}, "CPU") TaskContainerCreationOptsOSKey = bsonutil.MustHaveTag(TaskContainerCreationOptions{}, "OS") TaskContainerCreationOptsArchKey = bsonutil.MustHaveTag(TaskContainerCreationOptions{}, "Arch") TaskContainerCreationOptsEnvVarsKey = bsonutil.MustHaveTag(TaskContainerCreationOptions{}, "EnvVars") TaskContainerCreationOptsSecretsKey = bsonutil.MustHaveTag(TaskContainerCreationOptions{}, "EnvSecrets") TimeInfoInitializingKey = bsonutil.MustHaveTag(TimeInfo{}, "Initializing") TimeInfoStartingKey = bsonutil.MustHaveTag(TimeInfo{}, "Starting") TimeInfoLastCommunicatedKey = bsonutil.MustHaveTag(TimeInfo{}, "LastCommunicated") TimeInfoAgentStartedKey = bsonutil.MustHaveTag(TimeInfo{}, "AgentStarted") ResourceInfoExternalIDKey = bsonutil.MustHaveTag(ResourceInfo{}, "ExternalID") ResourceInfoDefinitionIDKey = bsonutil.MustHaveTag(ResourceInfo{}, "DefinitionID") ResourceInfoClusterKey = bsonutil.MustHaveTag(ResourceInfo{}, "Cluster") ResourceInfoContainersKey = bsonutil.MustHaveTag(ResourceInfo{}, "Containers") TaskRuntimeInfoRunningTaskIDKey = bsonutil.MustHaveTag(TaskRuntimeInfo{}, "RunningTaskID") TaskRuntimeInfoRunningTaskExecutionKey = bsonutil.MustHaveTag(TaskRuntimeInfo{}, "RunningTaskExecution") ContainerResourceInfoExternalIDKey = bsonutil.MustHaveTag(ContainerResourceInfo{}, "ExternalID") ContainerResourceInfoNameKey = bsonutil.MustHaveTag(ContainerResourceInfo{}, "Name") ContainerResourceInfoSecretIDsKey = bsonutil.MustHaveTag(ContainerResourceInfo{}, "SecretIDs") SecretExternalIDKey = bsonutil.MustHaveTag(Secret{}, "ExternalID") SecretValueKey = bsonutil.MustHaveTag(Secret{}, "Value") )
Functions ¶
func ByExternalID ¶
func CountByInitializing ¶
CountByInitializing counts the number of pods that are initializing but have not started any containers.
func UpdateOne ¶
func UpdateOne(query interface{}, update interface{}) error
UpdateOne updates one pod.
func UpdateOneStatus ¶
UpdateOneStatus updates a pod's status by ID along with any relevant metadata information about the status update. If the current status is identical to the updated one, this will no-op. If the current status does not match the stored status, this will error.
Types ¶
type Arch ¶
type Arch string
Arch represents recognized architectures for pods.
func ImportArch ¶
func ImportArch(arch evergreen.ContainerArch) (Arch, error)
ImportArch converts the container CPU architecture into its equivalent pod CPU architecture.
type ContainerResourceInfo ¶
type ContainerResourceInfo struct { // ExternalID is the unique resource identifier for the container running in // the container service. ExternalID string `bson:"external_id,omitempty" json:"external_id,omitempty"` // Name is the friendly name of the container. Name string `bson:"name,omitempty" json:"name,omitempty"` // SecretIDs are the resource identifiers for the secrets owned by this // container. SecretIDs []string `bson:"secret_ids,omitempty" json:"secret_ids,omitempty"` }
ContainerResourceInfo represents information about external resources associated with a container.
func (ContainerResourceInfo) IsZero ¶
func (i ContainerResourceInfo) IsZero() bool
IsZero implements the bsoncodec.Zeroer interface for the sake of defining the zero value for BSON marshalling.
type OS ¶
type OS string
OS represents a recognized operating system for pods.
func ImportOS ¶
func ImportOS(os evergreen.ContainerOS) (OS, error)
ImportOS converts the container OS into its equivalent pod OS.
type Pod ¶
type Pod struct { // ID is the unique identifier for the metadata document. ID string `bson:"_id" json:"id"` // Type indicates the type of pod that this is. Type Type `bson:"type" json:"type"` // Status is the current state of the pod. Status Status `bson:"status"` // TaskCreationOpts are options to configure how a task should be // containerized and run in a pod. TaskContainerCreationOpts TaskContainerCreationOptions `bson:"task_creation_opts,omitempty" json:"task_creation_opts,omitempty"` // Family is the family name of the pod definition stored in the cloud // provider. Family string `bson:"family,omitempty" json:"family,omitempty"` // TimeInfo contains timing information for the pod's lifecycle. TimeInfo TimeInfo `bson:"time_info,omitempty" json:"time_info,omitempty"` // Resources are external resources that are owned and managed by this pod. Resources ResourceInfo `bson:"resource_info,omitempty" json:"resource_info,omitempty"` // TaskRuntimeInfo contains information about the tasks that a pod is // assigned. TaskRuntimeInfo TaskRuntimeInfo `bson:"task_runtime_info,omitempty" json:"task_runtime_info,omitempty"` // AgentVersion is the version of the agent running on this pod if it's a // pod that runs tasks. AgentVersion string `bson:"agent_version,omitempty" json:"agent_version,omitempty"` }
Pod represents a related collection of containers. This model holds metadata about containers running in a container orchestration system.
func FindByInitializing ¶
FindByInitializing find all pods that are initializing but have not started any containers.
func FindByLastCommunicatedBefore ¶
FindByLastCommunicatedBefore finds all active pods whose last communication was before the given threshold.
func FindByNeedsTermination ¶
FindByNeedsTermination finds all pods running agents that need to be terminated, which includes: * Pods that have been provisioning for too long. * Pods that are decommissioned and have no running task.
func FindIntentByFamily ¶
FindIntentByFamily finds intent pods that have a matching family name.
func FindOneByExternalID ¶
FindOneByExternalID finds a pod that has a matching external identifier.
func NewTaskIntentPod ¶
func NewTaskIntentPod(ecsConf evergreen.ECSConfig, opts TaskIntentPodOptions) (*Pod, error)
NewTaskIntentPod creates a new intent pod to run container tasks from the given initialization options.
func (*Pod) ClearRunningTask ¶
ClearRunningTask clears the current task dispatched to the pod, if one is set.
func (*Pod) GetSecret ¶
GetSecret returns the shared secret between the server and the pod. If the secret is unset, this will return an error.
func (*Pod) Insert ¶
Insert inserts a new pod into the collection. This relies on the global Anser DB session.
func (*Pod) InsertWithContext ¶
InsertWithContext is the same as Insert, but it respects the given context by avoiding the global Anser DB session.
func (*Pod) SetRunningTask ¶
func (p *Pod) SetRunningTask(ctx context.Context, env evergreen.Environment, taskID string, taskExecution int) error
SetRunningTask sets the task to dispatch to the pod.
func (*Pod) UpdateAgentStartTime ¶
UpdateAgentStartTime updates the time when the pod's agent started to now.
func (*Pod) UpdateLastCommunicated ¶
UpdateLastCommunicated updates the last time that the pod and app server successfully communicated to now, indicating that the pod is currently alive.
func (*Pod) UpdateResources ¶
func (p *Pod) UpdateResources(info ResourceInfo) error
UpdateResources updates the pod resources.
type ResourceInfo ¶
type ResourceInfo struct { // ExternalID is the unique resource identifier for the aggregate collection // of containers running for the pod in the container service. ExternalID string `bson:"external_id,omitempty" json:"external_id,omitempty"` // DefinitionID is the resource identifier for the pod definition template. DefinitionID string `bson:"definition_id,omitempty" json:"definition_id,omitempty"` // Cluster is the namespace where the containers are running. Cluster string `bson:"cluster,omitempty" json:"cluster,omitempty"` // Containers include resource information about containers running in the // pod. Containers []ContainerResourceInfo `bson:"containers,omitempty" json:"containers,omitempty"` }
ResourceInfo represents information about external resources associated with a pod.
func (ResourceInfo) IsZero ¶
func (i ResourceInfo) IsZero() bool
IsZero implements the bsoncodec.Zeroer interface for the sake of defining the zero value for BSON marshalling.
type Secret ¶
type Secret struct { // ExternalID is the unique external resource identifier for a secret that // already exists in the secrets storage service. ExternalID string `bson:"external_id,omitempty" json:"external_id,omitempty"` // Value is the value of the secret. This is a cached copy of the actual // secret value stored in the secrets storage service. Value string `bson:"value,omitempty" json:"value,omitempty"` }
Secret is a sensitive secret that a pod can access. The secret is managed in an integrated secrets storage service.
type Status ¶
type Status string
Status represents a possible state for a pod.
const ( // StatusInitializing indicates that a pod is waiting to be created. StatusInitializing Status = "initializing" // StatusStarting indicates that a pod's containers are starting. StatusStarting Status = "starting" // StatusRunning indicates that the pod's containers are running. StatusRunning Status = "running" // StatusDecommissioned indicates that the pod is currently running but will // be terminated shortly. StatusDecommissioned Status = "decommissioned" // StatusTerminated indicates that all of the pod's containers and // associated resources have been deleted. StatusTerminated Status = "terminated" )
type StatusCount ¶
type StatusCount struct { Status Status `bson:"status"` Count int `bson:"count"` NumRunningTasks int `bson:"num_running_tasks"` }
StatusCount contains the total number of pods and total number of running tasks for a particular pod status.
func GetStatsByStatus ¶
func GetStatsByStatus(statuses ...Status) ([]StatusCount, error)
GetStatsByStatus gets aggregate usage statistics on pods that are intended for running tasks. For each pod status, it returns the counts for the number of pods and number of running tasks in that particular status. Terminated pods are excluded from these statistics.
type TaskContainerCreationOptions ¶
type TaskContainerCreationOptions struct { // Image is the image that the task's container will run. Image string `bson:"image" json:"image"` // RepoCredsExternalID is the external identifier for the repository // credentials. RepoCredsExternalID string `bson:"repo_creds_external_id,omitempty" json:"repo_creds_external_id,omitempty"` // MemoryMB is the memory (in MB) that the task's container will be // allocated. MemoryMB int `bson:"memory_mb" json:"memory_mb"` // CPU is the CPU units that the task will be allocated. 1024 CPU units is // equivalent to 1vCPU. CPU int `bson:"cpu" json:"cpu"` // OS indicates which particular operating system the pod's containers run // on. OS OS `bson:"os" json:"os"` // Arch indicates the particular architecture that the pod's containers run // on. Arch Arch `bson:"arch" json:"arch"` // WindowsVersion specifies the particular version of Windows the container // should run in. This only applies if OS is OSWindows. WindowsVersion WindowsVersion `bson:"windows_version,omitempty" json:"windows_version,omitempty"` // EnvVars is a mapping of the non-secret environment variables to expose in // the task's container environment. EnvVars map[string]string `bson:"env_vars,omitempty" json:"env_vars,omitempty"` // EnvSecrets are secret values to expose in the task's container // environment variables. The key is the name of the environment variable // and the value is the configuration for the secret value. EnvSecrets map[string]Secret `bson:"env_secrets,omitempty" json:"env_secrets,omitempty"` // WorkingDir is the working directory for the task's container. WorkingDir string `bson:"working_dir,omitempty" json:"working_dir,omitempty"` }
TaskContainerCreationOptions are options to apply to the task's container when creating a pod in the container orchestration service.
func (*TaskContainerCreationOptions) GetFamily ¶
func (o *TaskContainerCreationOptions) GetFamily(ecsConf evergreen.ECSConfig) string
GetFamily returns the family name for the cloud pod definition to be used for these container creation options.
func (*TaskContainerCreationOptions) Hash ¶
func (o *TaskContainerCreationOptions) Hash() string
Hash returns the hash digest of the creation options for the container. This is used to create a pod definition, which acts as a template for the actual pod that will run the container.
func (TaskContainerCreationOptions) IsZero ¶
func (o TaskContainerCreationOptions) IsZero() bool
IsZero implements the bsoncodec.Zeroer interface for the sake of defining the zero value for BSON marshalling.
type TaskIntentPodOptions ¶
type TaskIntentPodOptions struct { // ID is the pod identifier. If unspecified, it defaults to a new BSON // object ID. ID string CPU int MemoryMB int OS OS Arch Arch WindowsVersion WindowsVersion Image string RepoCredsExternalID string WorkingDir string PodSecretExternalID string PodSecretValue string }
TaskIntentPodOptions represents options to create an intent pod that runs container tasks.
type TaskRuntimeInfo ¶
type TaskRuntimeInfo struct { // RunningTaskID is the ID of the task currently running on the pod. RunningTaskID string `bson:"running_task_id,omitempty" json:"running_task_id,omitempty"` // RunningTaskExecution is the execution number of the task currently // running on the pod. RunningTaskExecution int `bson:"running_task_execution,omitempty" json:"running_task_execution,omitempty"` }
TaskRuntimeInfo contains information for pods running tasks about the tasks that it is running or has run previously.
func (TaskRuntimeInfo) IsZero ¶
func (i TaskRuntimeInfo) IsZero() bool
IsZero implements the bsoncodec.Zeroer interface for the sake of defining the zero value for BSON marshalling.
type TimeInfo ¶
type TimeInfo struct { // Initializing is the time when this pod was initialized and is waiting to // be created in the container orchestration service. This should correspond // with the time when the pod transitions to the "initializing" status. Initializing time.Time `bson:"initializing,omitempty" json:"initializing,omitempty"` // Starting is the time when this pod was actually requested to start its // containers. This should correspond with the time when the pod transitions // to the "starting" status. Starting time.Time `bson:"starting,omitempty" json:"starting,omitempty"` // LastCommunicated is the last time that the pod connected to the // application server or the application server connected to the pod. This // is used as one indicator of liveliness. LastCommunicated time.Time `bson:"last_communicated,omitempty" json:"last_communicated,omitempty"` // AgentStarted is the time that the agent initiated first contact with the // application server. This only applies to agent pods. AgentStarted time.Time `bson:"agent_started,omitempty" json:"agent_started,omitempty"` }
TimeInfo represents timing information about the pod.
type Type ¶
type Type string
Type is the type of pod.
const ( // TypeAgent indicates that it is a pod that is running the Evergreen agent // in a container. TypeAgent Type = "agent" )
type WindowsVersion ¶
type WindowsVersion string
WindowsVersion represents a specific version of Windows that a pod is allowed to run on. This only applies to pods running Windows containers.
const ( // WindowsVersionServer2016 indicates that a pod is compatible to run on an // instance that is running Windows Server 2016. WindowsVersionServer2016 WindowsVersion = "SERVER_2016" // WindowsVersionServer2016 indicates that a pod is compatible to run on an // instance that is running Windows Server 2019. WindowsVersionServer2019 WindowsVersion = "SERVER_2019" // WindowsVersionServer2016 indicates that a pod is compatible to run on an // instance that is running Windows Server 2022. WindowsVersionServer2022 WindowsVersion = "SERVER_2022" )
func ImportWindowsVersion ¶
func ImportWindowsVersion(winVer evergreen.WindowsVersion) (WindowsVersion, error)
ImportWindowsVersion converts the container Windows version into its equivalent pod Windows version.
func (WindowsVersion) Matches ¶
func (v WindowsVersion) Matches(other evergreen.ECSWindowsVersion) bool
Matches returns whether or not the pod Windows Version matches the given Evergreen ECS config Windows version.
func (WindowsVersion) Validate ¶
func (v WindowsVersion) Validate() error
Validate checks that the pod Windows version is recognized.
Directories ¶
Path | Synopsis |
---|---|
Package definition contains the data model for the pod definition cache.
|
Package definition contains the data model for the pod definition cache. |
Package dispatcher models a queue of tasks that are dispatched to a group of pods.
|
Package dispatcher models a queue of tasks that are dispatched to a group of pods. |