cleanup container state if the reader tomb dies by itself (#1470)
This commit is contained in:
parent
242706a475
commit
8909fbdb22
|
@ -507,6 +507,15 @@ func (d *DockerSource) TailDocker(container *ContainerConfig, outChan chan types
|
|||
linesRead.With(prometheus.Labels{"source": container.Name}).Inc()
|
||||
outChan <- evt
|
||||
d.logger.Debugf("Sent line to parsing: %+v", evt.Line.Raw)
|
||||
case <-readerTomb.Dying():
|
||||
//This case is to handle temporarly losing the connection to the docker socket
|
||||
//The only known case currently is when using docker-socket-proxy (and maybe a docker daemon restart)
|
||||
d.logger.Debugf("readerTomb dying for container %s, removing it from runningContainerState", container.Name)
|
||||
delete(d.runningContainerState, container.ID)
|
||||
//Also reset the Since to avoid re-reading logs
|
||||
d.Config.Since = time.Now().UTC().Format(time.RFC3339)
|
||||
d.containerLogsOptions.Since = d.Config.Since
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -183,7 +183,7 @@ container_name_regexp:
|
|||
ticker.Reset(1 * time.Second)
|
||||
case <-ticker.C:
|
||||
log.Infof("no more line to read")
|
||||
readerTomb.Kill(nil)
|
||||
streamTomb.Kill(nil)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue