From 74c0c5b7f1a90bead853e98c7f77936caffba8d2 Mon Sep 17 00:00:00 2001 From: Patrick Haas Date: Wed, 30 Sep 2020 14:52:22 -0700 Subject: [PATCH] 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 (cherry picked from commit ef553e14a4e27fc479b9c8e94d76654ec67694fe) Signed-off-by: Sebastiaan van Stijn --- daemon/logger/gcplogs/gcplogging.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/daemon/logger/gcplogs/gcplogging.go b/daemon/logger/gcplogs/gcplogging.go index 1699f67a2d..90d5f7b162 100644 --- a/daemon/logger/gcplogs/gcplogging.go +++ b/daemon/logger/gcplogs/gcplogging.go @@ -53,6 +53,7 @@ func init() { } type gcplogs struct { + client *logging.Client logger *logging.Logger instance *instanceInfo container *containerInfo @@ -169,6 +170,7 @@ func New(info logger.Info) (logger.Logger, error) { } l := &gcplogs{ + client: c, logger: lg, container: &containerInfo{ Name: info.ContainerName, @@ -236,7 +238,7 @@ func (l *gcplogs) Log(m *logger.Message) error { func (l *gcplogs) Close() error { l.logger.Flush() - return nil + return l.client.Close() } func (l *gcplogs) Name() string {