-
Notifications
You must be signed in to change notification settings - Fork 613
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
engine: docker healthcheck logLength index fix #1239
Conversation
I was able to reproduce this state of the health check using this Dockerfile: FROM debian:latest
HEALTHCHECK --interval=3s --timeout=1s --start-period=56s CMD /bin/true
CMD ["/bin/sleep", "60"] And running it using the following commands: docker build -t healthchecked .
docker run -d --name healthchecked healthchecked
# wait for container to start
sleep 2
# check the container's state for health checks observed:
docker inspect -f '{{.State.Health}}' healthchecked Which shows the health state with no checks performed and still in the starting state:
|
efd0cbe
to
340c279
Compare
@jahkeup in your example, the container's health status is |
Yep, I see where we're checking the logs now. Let me try this out with the Agent running to see if there's some other way that the logs could be empty. |
Doesn't appear that we could easily get into this state, the Docker daemon always appends to its Log field when handling a check result and this is also where it's setting the unhealthy/healthy status. |
340c279
to
97ce936
Compare
97ce936
to
4a5655d
Compare
@adnxn don't forget to add an entry in the chanelog before merging this. |
f542bba
to
109af5f
Compare
Summary
This change addresses #1237 by adding a zero check before accessing the
Health.Log
slice. Also adds corresponding test.The issue was surfaced when the agent recieved a Docker health check message indicating the container was
unhealthy
but sent an empty[]HealthCheck
inHealth.Log
.We have not reproduced the issue, but are handling this case by doing a length check on
Health.Log
.Implementation details
Testing
make release
)go build -out amazon-ecs-agent.exe ./agent
)make test
) passgo test -timeout=25s ./agent/...
) passmake run-integ-tests
) pass.\scripts\run-integ-tests.ps1
) passmake run-functional-tests
) pass.\scripts\run-functional-tests.ps1
) passNew tests cover the changes:
Description for the changelog
Licensing
This contribution is under the terms of the Apache 2.0 License: