Skip to content

Commit

Permalink
libct/StartInitialization: rename returned error
Browse files Browse the repository at this point in the history
This makes the code more straightforward about when are we using it.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
  • Loading branch information
kolyshkin committed Aug 4, 2022
1 parent 3ea88ba commit c739db2
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions libcontainer/init_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ type initConfig struct {
// StartInitialization loads a container by opening the pipe fd from the parent
// to read the configuration and state. This is a low level implementation
// detail of the reexec and should not be consumed externally.
func StartInitialization() (err error) {
func StartInitialization() (retErr error) {
var err error

// Set up logging.
level := int(logrus.DebugLevel) // default to debug
// Passing log level is optional; currently libcontainer/integration does not do it.
Expand Down Expand Up @@ -115,11 +117,11 @@ func StartInitialization() (err error) {
defer func() {
// 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 {
if err := writeSync(pipe, procError); err != nil {
fmt.Fprintln(os.Stderr, err)
return
}
if werr := utils.WriteJSON(pipe, &initError{Message: err.Error()}); werr != nil {
if err := utils.WriteJSON(pipe, &initError{Message: retErr.Error()}); err != nil {
fmt.Fprintln(os.Stderr, err)
return
}
Expand Down Expand Up @@ -157,11 +159,11 @@ func StartInitialization() (err error) {
os.Clearenv()

defer func() {
if e := recover(); e != nil {
if ee, ok := e.(error); ok {
err = fmt.Errorf("panic from initialization: %w, %s", ee, debug.Stack())
if err := recover(); err != nil {
if err2, ok := err.(error); ok {
retErr = fmt.Errorf("panic from initialization: %w, %s", err2, debug.Stack())
} else {
err = fmt.Errorf("panic from initialization: %v, %s", e, debug.Stack())
retErr = fmt.Errorf("panic from initialization: %v, %s", err, debug.Stack())
}
}
}()
Expand Down

0 comments on commit c739db2

Please sign in to comment.