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 <kolyshkin@gmail.com>
This commit is contained in:
Kir Kolyshkin
2021-08-04 20:13:39 -07:00
parent 9ba2f65d6b
commit d974b22ac4
2 changed files with 8 additions and 7 deletions
+6 -6
View File
@@ -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)
},
}
+2 -1
View File
@@ -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)
},
}