-
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
Issue a stop when start container failed with EOF error #2245
Conversation
49d48ad
to
f8a68b7
Compare
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.
change lgtm, nonblocking nit.
When start container failed with EOF there's a chance that the container is started anyway, so issue a stop for this case.
f8a68b7
to
adbf4a9
Compare
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.
looks good.
// a stop. See #1043 for details | ||
shouldForceStop = true | ||
} else if errorName == dockerapi.CannotStartContainerErrorName && strings.HasSuffix(errorStr, io.EOF.Error()) { | ||
// If we get an EOF error from Docker when starting the container, we don't really know whether the |
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.
do we know when does an EOF error occur?
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.
From my understanding, an EOF means the client didn't read anything from the response, which can happen if the connection closes before server writes the response.
Summary
Fix #1708. When start container failed with EOF, there's a chance that the container is started anyway, so issue a stop for the container in that case.
Implementation details
The stop is issued in
handleEventErroor
, in the same way as how we issue a stop when start container times out. I can't find a typed error from Docker or golang for this, so check is based on the error string.Testing
Unit test added. Manually tested by injecting the error in docker client and verified that the container is forced to stop.
Description for the changelog
Fixed a bug where the agent could lose track of running containers upon certain Docker API error #2245.
Licensing
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.