Merge pull request #5332 from hashicorp/dani/docker_logger_container_leak

docker: Avoid leaking containers during Reattach
This commit is contained in:
Danielle Tomlinson 2019-02-20 22:53:06 +01:00 committed by GitHub
commit b08e6e5925
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -199,16 +199,16 @@ func (d *Driver) RecoverTask(handle *drivers.TaskHandle) error {
h.dlogger, h.dloggerPluginClient, err = d.setupNewDockerLogger(container, handle.Config, time.Now()) h.dlogger, h.dloggerPluginClient, err = d.setupNewDockerLogger(container, handle.Config, time.Now())
if err != nil { if err != nil {
// TODO(dani): FIXME: Here we will leak the users container. Simply removing if err := client.StopContainer(handleState.ContainerID, 0); err != nil {
// the container here will cause a user restart-stanza d.logger.Warn("failed to stop container during cleanup", "container_id", handleState.ContainerID, "error", err)
// based cycle. }
return fmt.Errorf("failed to setup replacement docker logger: %v", err) return fmt.Errorf("failed to setup replacement docker logger: %v", err)
} }
if err := handle.SetDriverState(h.buildState()); err != nil { if err := handle.SetDriverState(h.buildState()); err != nil {
// TODO(dani): FIXME: Here we will leak the users container. Simply removing if err := client.StopContainer(handleState.ContainerID, 0); err != nil {
// the container here will cause a user restart-stanza d.logger.Warn("failed to stop container during cleanup", "container_id", handleState.ContainerID, "error", err)
// based cycle. }
return fmt.Errorf("failed to store driver state: %v", err) return fmt.Errorf("failed to store driver state: %v", err)
} }
} }