runc/patch/0130-runc-fix-cgroup-info-print-error.patch

41 lines
1.2 KiB
Diff
Raw Normal View History

From 40dd39dea67339fdcb88e64e52d054648fcbd362 Mon Sep 17 00:00:00 2001
From: zhongjiawei <zhongjiawei1@huawei.com>
Date: Tue, 5 Jul 2022 17:28:48 +0800
2022-08-09 14:31:04 +08:00
Subject: [PATCH] runc: fix cgroup info print error
reason: still using syslog hook to print logrus in create-init,
as logPipe will be closed before printCgroupInfo() called, cgroup info
could not be printed by logPipe.
---
main_unix.go | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
2022-08-09 14:31:04 +08:00
diff --git a/main_unix.go b/main_unix.go
index 45e6df61..04799491 100644
2022-08-09 14:31:04 +08:00
--- a/main_unix.go
+++ b/main_unix.go
@@ -19,13 +19,14 @@ func init() {
runtime.GOMAXPROCS(1)
runtime.LockOSThread()
- logPipeFd, err := strconv.Atoi(os.Getenv("_LIBCONTAINER_LOGPIPE"))
- if err != nil {
- return
+ if initType := os.Getenv("_LIBCONTAINER_INITTYPE"); initType == "setns" {
+ logPipeFd, err := strconv.Atoi(os.Getenv("_LIBCONTAINER_LOGPIPE"))
+ if err != nil {
+ return
+ }
+ logrus.SetOutput(os.NewFile(uintptr(logPipeFd), "logpipe"))
+ logrus.SetFormatter(new(logrus.JSONFormatter))
}
- logrus.SetOutput(os.NewFile(uintptr(logPipeFd), "logpipe"))
- logrus.SetFormatter(new(logrus.JSONFormatter))
- logrus.Info("child process init-function finished")
}
}
--
2.30.0
2022-08-09 14:31:04 +08:00