From d974b22ac4877d15348f6747608be799bf5c343a Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Wed, 4 Aug 2021 20:13:39 -0700 Subject: [PATCH] create, run: amend final errors As the error may contain anything, it may not be clear to a user that the whole (create or run) operation failed. Amend the errors. Also, change the code flow in create to match that of run, so we don't have to add the fake "return nil" at the end. Signed-off-by: Kir Kolyshkin --- create.go | 12 ++++++------ run.go | 3 ++- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/create.go b/create.go index a27e7c45f..97854b846 100644 --- a/create.go +++ b/create.go @@ -1,6 +1,7 @@ package main import ( + "fmt" "os" "github.com/urfave/cli" @@ -56,12 +57,11 @@ command(s) that get executed on start, edit the args parameter of the spec. See return err } status, err := startContainer(context, CT_ACT_CREATE, nil) - if err != nil { - return err + if err == nil { + // exit with the container's exit status so any external supervisor + // is notified of the exit with the correct exit status. + os.Exit(status) } - // exit with the container's exit status so any external supervisor is - // notified of the exit with the correct exit status. - os.Exit(status) - return nil + return fmt.Errorf("runc create failed: %w", err) }, } diff --git a/run.go b/run.go index 4c46f4f6c..82781669d 100644 --- a/run.go +++ b/run.go @@ -1,6 +1,7 @@ package main import ( + "fmt" "os" "github.com/urfave/cli" @@ -74,6 +75,6 @@ command(s) that get executed on start, edit the args parameter of the spec. See // notified of the exit with the correct exit status. os.Exit(status) } - return err + return fmt.Errorf("runc run failed: %w", err) }, }