Merge pull request #5332 from hashicorp/dani/docker_logger_container_leak
docker: Avoid leaking containers during Reattach
This commit is contained in:
commit
b08e6e5925
|
@ -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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue