1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Fix gcplogs memory/connection leak

The cloud logging client should be closed when the log driver is closed. Otherwise dockerd will keep a gRPC connection to the logging endpoint open indefinitely.

This results in a slow leak of tcp sockets (1) and memory (~200Kb) any time that a container using `--log-driver=gcplogs` is terminates.

Signed-off-by: Patrick Haas <patrickhaas@google.com>
(cherry picked from commit ef553e14a4)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Patrick Haas 2020-09-30 14:52:22 -07:00 committed by Sebastiaan van Stijn
parent 88623e101c
commit 74c0c5b7f1
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C

View file

@ -53,6 +53,7 @@ func init() {
} }
type gcplogs struct { type gcplogs struct {
client *logging.Client
logger *logging.Logger logger *logging.Logger
instance *instanceInfo instance *instanceInfo
container *containerInfo container *containerInfo
@ -169,6 +170,7 @@ func New(info logger.Info) (logger.Logger, error) {
} }
l := &gcplogs{ l := &gcplogs{
client: c,
logger: lg, logger: lg,
container: &containerInfo{ container: &containerInfo{
Name: info.ContainerName, Name: info.ContainerName,
@ -236,7 +238,7 @@ func (l *gcplogs) Log(m *logger.Message) error {
func (l *gcplogs) Close() error { func (l *gcplogs) Close() error {
l.logger.Flush() l.logger.Flush()
return nil return l.client.Close()
} }
func (l *gcplogs) Name() string { func (l *gcplogs) Name() string {