-
Notifications
You must be signed in to change notification settings - Fork 618
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add MANIFEST_PULLED internal container and task states #4137
Conversation
159d1dc
to
4a5ca7c
Compare
c742eb3
to
8f2d145
Compare
@@ -3682,7 +3685,8 @@ func (task *Task) ToHostResources() map[string]*ecs.Resource { | |||
func (task *Task) HasActiveContainers() bool { | |||
for _, container := range task.Containers { | |||
containerStatus := container.GetKnownStatus() | |||
if containerStatus >= apicontainerstatus.ContainerPulled && containerStatus <= apicontainerstatus.ContainerResourcesProvisioned { | |||
if containerStatus >= apicontainerstatus.ContainerManifestPulled && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: this if-statement seems like it would make more sense to be containerStatus > ContainerStatusNone && containerStatus < ContainerStatusStopped
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah with current states both are equivalent but I get your point. It's a bit out of scope of this PR so I'd rather not change that logic here.
Summary
This PR adds a new
ContainerState
namedContainerManifestPulled
and a newTaskState
calledTaskManifestPulled
.ContainerManifestPulled
is added betweenContainerStatusNone
andContainerPulled
states and similarlyTaskManifestPulled
is added betweenTaskStatusNone
andTaskPulled
states.A new state transition function
pullContainerManifest
is added toDockerTaskEngine
for handling transition of a container toContainerManifestPulled
state. The transition function is a no-op currently but will be updated in a future change to pull the manifest of the container image. This is a part of a project to expedite the reporting of container image manifest digests to ECS backend.Containers that want to reach steady state are allowed to transition to
ContainerManifestPulled
state under either of the following conditions -Container ordering dependencies are disregarded for transition to
ContainerManifestPulled
state. This is so that image manifest digests of all images of a task can be reported as soon as possible.ContainerManifestPulled
state maps toTaskManifestPulled
state when computing the known status of a task.None of the new states generate new state change events as of this PR, so container and tasks transitioning to these new states will not result in any new STSC calls.
Implementation details
ContainerManifestPulled ContainerStatus
constant tocontainerstatus
package and update string mappings ofContainerStatus
so thatContainerManifestPulled
is mapped to "MANIFEST_PULLED" string. Update tests accordingly.TaskManifestPulled TaskStatus
constant totaskstatus
package and update string mappings ofTaskStatus
so thatTaskManifestPulled
is mapped to "MANIFEST_PULLED" string. Update tests accordingly.pullContainerManifest
method toDockerTaskEngine
type. This method is the transition function for transitioning a container toContainerManifestPulled
state. The method is currently a no-op. UpdateDockerTaskEngine.containerStatusToTransitionFunction
map with a newapicontainerstatus.ContainerManifestPulled: engine.pullContainerManifest
entry accordingly.managedTask.handleEventError
method to handle errors generated in the new state transition function. The error handling logic is the same as that forContainerPulled
state transition errors. This is because we want to treat manifest pulls as a part of image pulls and hence we want to have the same error handling for both.Task.initializeASMAuthResource
method so that a container's transition toContainerManifestPulled
state depends on the creation of the task's ASM Auth resource that is used to resolve private registry credentials. This is because private registry credentials will be needed for manifest pulls.Testing
Updated existing unit tests and added new unit tests.
Added a new integration test that checks -
MANIFEST_PULLED
state.MANIFEST_PULLED
state does not depend on container ordering.Following manual tests were also performed.
Ran a simple task with a single container and observed the following in the logs.
MANIFEST_PULLED
state before transitioning toPULLED
state as expected.MANIFEST_PULLED
did not qualify for a state change event as expected.MANIFEST_PULLED
state after the container transitioned toMANIFEST_PULLED
state as expected.MANIFEST_PULLED
state did not qualify for a state change event as expected.EssentialContainerExited
and the container stopped with successful exit code0
.Ran a task with two containers with one container depending on other container's completion. Both containers passed
MANIFEST_PULLED
state with the dependent container waiting inMANIFEST_PULLED
state until the dependency container completed.Ran a task with one container whose image is in a private Dockerhub registry. The container did not transition to
MANIFEST_PULLED
state until the task's ASM Auth resource for private registry credentials reachedCREATED
state which is expected.New tests cover the changes: yes
Description for the changelog
Does this PR include breaking model changes? If so, Have you added transformation functions?
Enhancement: Add a new
MANIFEST_PULLED
container and task state. The transition function for this state is currently a no-op.Licensing
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.