Skip to content
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

dependencygraph: Enforce shutdown order #1866

Merged

Conversation

petderek
Copy link
Contributor

Summary

Enforce shutdown ordering within a task.

Implementation details

We now apply shutdown order in any dependency case, including
dependsOn directives, links, or volumes. What this means is that
agent will now make a best effort attempt to shutdown containers
in the inverse order they were created.

For example, a container using a link for communication will wait
until the linked container has terminated before terminating
itself. Likewise, a container named in another container's
dependsOn directive will wait until that dependent container
terminates.

One note about the current implementation is that the dependencies
aren't assumed to be transitive, so if a chain exists such that:

A -> B -> C

Container "C" will shutdown before "B", but it won't check status
against container "A" explicity. If A depends on C, we expect:

A -> B -> C
A -> C

The lack of transitive dependency logic applies is consistent with
startup order as of this commit.

Testing

Added additional tests to cover the shutdown use cases.

Licensing

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@petderek petderek force-pushed the container-ordering-feature branch from 435b6b5 to 6ec0db1 Compare February 18, 2019 23:14
@petderek petderek force-pushed the container-ordering-feature branch 3 times, most recently from c983940 to b33029c Compare February 21, 2019 21:16
Copy link
Contributor

@sharanyad sharanyad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

once tests pass

agent/engine/dependencygraph/graph.go Outdated Show resolved Hide resolved
@adnxn
Copy link
Contributor

adnxn commented Feb 22, 2019

are the ft failures due to timeouts?

@petderek
Copy link
Contributor Author

Great question. They were passing before i rebased 😖

@petderek petderek force-pushed the container-ordering-feature branch 4 times, most recently from 492919c to 0d7f7fe Compare February 22, 2019 07:12
@petderek
Copy link
Contributor Author

petderek commented Feb 22, 2019

Unit tests are both passing in travis. The linux test isn't failing; CI is just reporting failed for some reason?

Nevermind, it was panicking. I'm looking into it

We now apply shutdown order in any dependency case, including
dependsOn directives, links, or volumes. What this means is that
agent will now make a best effort attempt to shutdown containers
in the inverse order they were created.

For example, a container using a link for communication will wait
until the linked container has terminated before terminating
itself. Likewise, a container named in another container's
dependsOn directive will wait until that dependent container
terminates.

One note about the current implementation is that the dependencies
aren't assumed to be transitive, so if a chain exists such that:

A -> B -> C

Container "C" will shutdown before "B", but it won't check status
against container "A" explicity. If A depends on C, we expect:

A -> B -> C
     A -> C

The lack of transitive dependency logic applies is consistent with
startup order as of this commit.
The link / volume dependency tests are now affected by shutdown
order, so the tests now take longer. Previously, it would take a
max of 30s (the default docker stop timeout for agent). Now, since
the containers stop in order, it will take a max of 30s * n, where
n is the number of containers.

Increasing the test timeout is a short term fix until we have
granular start/stop timeouts plumbed through the ecs service.
Instead of explicitly checking against many conditions, we now
validate that the expected condition has progressed beyond started

This mirrors prior behavior in the codebase, and reduces cyclo
complexity.
@petderek petderek force-pushed the container-ordering-feature branch from 0d7f7fe to 89bb2e8 Compare February 22, 2019 17:20
@petderek
Copy link
Contributor Author

Logdriver test is failing suddenly. I've made a note to fix the test in #1835

@petderek petderek merged commit 582327c into aws:container-ordering-feature Feb 22, 2019
@ellenthsu ellenthsu added this to the 1.26.0 milestone Feb 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants