From d57fceb434da7bd2f4cf910242cfddb39cda1376 Mon Sep 17 00:00:00 2001 From: Andre Kurait Date: Mon, 23 Nov 2026 20:19:17 -0600 Subject: [PATCH] fix(docker): use non-blocking GELF delivery (#9317) Docker's GELF driver now runs in non-blocking mode, so a listener outage no longer blocks a container's log writes or skips the daemon's local log copy. docker.md describes the default 1 MB delivery buffer and the live console and CloudWatch Logs loss once it fills. Signed-off-by: Andre Kurait --- docs/configuration/docker.md | 2 ++ .../java/io/floci/aws/core/common/docker/GelfLogListener.java | 1 + .../io/floci/aws/core/common/docker/GelfLogListenerTest.java | 2 ++ 3 files changed, 5 insertions(+) diff --git a/docs/configuration/docker.md b/docs/configuration/docker.md index 44f9b10c13..d26df89531 100644 --- a/docs/configuration/docker.md +++ b/docs/configuration/docker.md @@ -260,6 +260,8 @@ Docker opens that connection itself, from wherever the daemon runs, so the mode The daemon's local copy of the log (dual logging, on by default since Docker Engine 20.10) is what `docker logs`, the RDS log-file APIs and the fallback below read, so keep it on; `log-max-size` and `log-max-file` bound it. +GELF delivery uses Docker's non-blocking mode so a listener outage does not block application log writes. Its per-container delivery buffer uses Docker's default size of `1m` (1 MB). When that buffer fills, Docker drops new messages: the live console and CloudWatch Logs streams are not lossless under sustained backpressure. Increasing the buffer only delays overflow. The local dual-log copy and polling fallback do not guarantee recovery of messages dropped before delivery, and `log-max-size` and `log-max-file` control local rotation, not this delivery buffer. + Docker keeps the listener's address in each container's log configuration and dials it every time the container starts, so the listener takes a fixed port, `log-driver-port` (12201, GELF's standard port), and Floci opens it before it starts any container. A stopped container that Floci adopts after a restart therefore starts again. The port must be free on Floci's host. A container created with another `log-driver-port` or `log-driver-host` keeps dialing the old address: Floci reads its log on a timer from the local copy and logs a warning, and once stopped it starts again only after the setting is restored or the resource is recreated. `log-driver-host` overrides the host the daemon dials. When it names an address of Floci's own host (Floci's address on a Docker network, for example), the listener binds that address instead of loopback; the listener has no authentication beyond each container's random tag, so only point it at a network you trust: diff --git a/src/main/java/io/floci/aws/core/common/docker/GelfLogListener.java b/src/main/java/io/floci/aws/core/common/docker/GelfLogListener.java index 55ea55514b..19cb4d67ce 100644 --- a/src/main/java/io/floci/aws/core/common/docker/GelfLogListener.java +++ b/src/main/java/io/floci/aws/core/common/docker/GelfLogListener.java @@ -118,6 +118,7 @@ public class GelfLogListener { Map options = new HashMap<>(); options.put("gelf-address", "tcp://" + ensureStarted()); options.put("tag", token); + options.put("mode", "non-blocking"); if (jsonFileOptions != null) { copyOption(jsonFileOptions, "max-size", options, "cache-max-size"); copyOption(jsonFileOptions, "max-file", options, "cache-max-file"); diff --git a/src/test/java/io/floci/aws/core/common/docker/GelfLogListenerTest.java b/src/test/java/io/floci/aws/core/common/docker/GelfLogListenerTest.java index fd40ce8aa9..50ae732beb 100644 --- a/src/test/java/io/floci/aws/core/common/docker/GelfLogListenerTest.java +++ b/src/test/java/io/floci/aws/core/common/docker/GelfLogListenerTest.java @@ -121,6 +121,8 @@ class GelfLogListenerTest { LogConfig logConfig = listener.logConfigFor("token-a", ROTATION); assertEquals(LogConfig.LoggingType.GELF, logConfig.getType()); assertEquals("token-a", logConfig.getConfig().get("tag")); + assertEquals("non-blocking", logConfig.getConfig().get("mode"), + "failed GELF delivery must not skip the daemon's local copy"); assertEquals("10m", logConfig.getConfig().get("cache-max-size"), "the rotation bounds the daemon's copy"); assertEquals("3", logConfig.getConfig().get("cache-max-file")); String address = logConfig.getConfig().get("gelf-address");