41 lines
1.5 KiB
Diff
41 lines
1.5 KiB
Diff
From 0f97a1c1668827086dfa335c9fb427cbb28782b2 Mon Sep 17 00:00:00 2001
|
|
From: Lukas Zapletal <lzap+git@redhat.com>
|
|
Date: Thu, 11 Sep 2025 08:03:21 +0200
|
|
Subject: [PATCH] common: fix unclosed logrus logging pipes
|
|
|
|
This is a backport of 1cde7e3. The original patch was not separated into
|
|
individual commits unfortunately, there fore only the relevant line is
|
|
being brought in. The original analysis:
|
|
|
|
It looks like both CloudAPI and WeldrAPI consume memory, process can go
|
|
up to several gigabytes pretty quickly just by running a simple script.
|
|
|
|
while sleep 0.001; do
|
|
curl --unix-socket /run/weldr/api.socket -XGET http://localhost/api/
|
|
curl --unix-socket /run/cloudapi/api.socket -XGET http://localhost/api/
|
|
done
|
|
|
|
There is a logrus logger method called Write and WriteLevel which create
|
|
a new logging entry, create a PIPE and spawn a goroutine that is reading
|
|
from that PIPE. The caller is expected to close the PIPE writer which
|
|
was not done.
|
|
---
|
|
internal/common/echo_logrus.go | 6 +++++-
|
|
1 file changed, 5 insertions(+), 1 deletion(-)
|
|
|
|
diff --git a/internal/common/echo_logrus.go b/internal/common/echo_logrus.go
|
|
index 198ce17310..600cce2d74 100644
|
|
--- a/internal/common/echo_logrus.go
|
|
+++ b/internal/common/echo_logrus.go
|
|
@@ -178,5 +178,9 @@ func (l *EchoLogrusLogger) Panicj(j lslog.JSON) {
|
|
}
|
|
|
|
func (l *EchoLogrusLogger) Write(p []byte) (n int, err error) {
|
|
- return l.Logger.WithContext(l.Ctx).Writer().Write(p)
|
|
+ // Writer() from logrus returns PIPE that needs to be closed
|
|
+ w := l.Logger.WithContext(l.Ctx).Writer()
|
|
+ defer w.Close()
|
|
+
|
|
+ return w.Write(p)
|
|
}
|