Reopen Docker event stream when getting EOF error #2240
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Fix #591.
Previously, agent did not reopen docker event stream when it gets EOF/UnexpectedEOF error. When fsouza/go-dockerclient was used, we had this behavior because fsouza/go-dockerclient can't reopen the stream upon EOF/UnexpectedEOF due to some of its own implementation details (see fsouza/go-dockerclient#171) and we did not retry in our layer. When migrated to docker/docker/client, this behavior was maintained.
In the case that Docker is restarted (and container live-restore is enabled), agent's event stream listening goroutine gets an io.UnexpectedEOF and finishes, and we never open the stream again and as a result loss all Docker events until the agent is restarted. So making this changes to reopen Docker event stream when getting EOF error.
Implementation details
Few changes in ContainerEvents.
Testing
Updated the TestContainerEventsEOFError to conform with new behavior.
Manually tested with the steps to reproduce described in #591 and verified that it's fixed.
Description for the changelog
Fixed a bug where when Docker container live restore is enabled, agent stops listening to Docker container event after Docker restarts #2240.
Licensing
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.