runc/patch/0041-runc-libct-init-unify-init-fix-its-error-logic.patch
zhongjiawei 26bd3e8e1c runc:fix init error return logic
(cherry picked from commit 435221ff67d08acd4177fc6e6727c0d118823e2b)
2023-09-18 17:11:44 +08:00

46 lines
1.4 KiB
Diff

From eecf5dd404208161292f0c10e6118eefea5e62f3 Mon Sep 17 00:00:00 2001
From: Kir Kolyshkin <kolyshkin@gmail.com>
Date: Wed, 9 Aug 2023 12:04:26 +0900
Subject: [PATCH] libct/init: unify init, fix its error logic
Fix init error handling logic.
The main issues at hand are:
- the "unable to convert _LIBCONTAINER_INITPIPE" error from
StartInitialization is never shown;
- errors from WriteSync and WriteJSON are never shown;
Generally, our goals are:
- if there's any error, do our best to show it;
- but only show each error once;
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
---
libcontainer/factory_linux.go | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/libcontainer/factory_linux.go b/libcontainer/factory_linux.go
index 39fc312..a4628b8 100644
--- a/libcontainer/factory_linux.go
+++ b/libcontainer/factory_linux.go
@@ -288,13 +288,14 @@ func (l *LinuxFactory) StartInitialization() (err error) {
// We have an error during the initialization of the container's init,
// send it back to the parent process in the form of an initError.
if werr := writeSync(pipe, procError); werr != nil {
- fmt.Fprintln(os.Stderr, err)
+ fmt.Fprintln(os.Stderr, werr)
return
}
if werr := utils.WriteJSON(pipe, &initError{Message: err.Error()}); werr != nil {
- fmt.Fprintln(os.Stderr, err)
+ fmt.Fprintln(os.Stderr, werr)
return
}
+ err = nil
}()
// Only init processes have FIFOFD.
--
2.33.0