summaryrefslogtreecommitdiff
path: root/cmd/podman/images
diff options
context:
space:
mode:
authorAditya Rajan <arajan@redhat.com>2021-12-16 17:07:16 +0530
committerAditya Rajan <arajan@redhat.com>2021-12-17 15:07:50 +0530
commitf566d8b8e5351393c03bc0ff475a18174e57af3f (patch)
tree9235af4b6f3d16bc166202a34100d71b9750e407 /cmd/podman/images
parentd984fec351c06a95f8a51c7e6ced819c6b17245f (diff)
downloadpodman-f566d8b8e5351393c03bc0ff475a18174e57af3f.tar.gz
podman-f566d8b8e5351393c03bc0ff475a18174e57af3f.tar.bz2
podman-f566d8b8e5351393c03bc0ff475a18174e57af3f.zip
build: relay exitcode from imagebuildah to registry
Podman does not relay exit code from buildah instead returns a generic error code `125`. Following PR allows `podman` to relay exit code from `imagebuildah` to `registry` as it is. Signed-off-by: Aditya Rajan <arajan@redhat.com>
Diffstat (limited to 'cmd/podman/images')
-rw-r--r--cmd/podman/images/build.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/cmd/podman/images/build.go b/cmd/podman/images/build.go
index 4c563ed27..751db099f 100644
--- a/cmd/podman/images/build.go
+++ b/cmd/podman/images/build.go
@@ -1,9 +1,11 @@
package images
import (
+ "fmt"
"io"
"io/ioutil"
"os"
+ "os/exec"
"path/filepath"
"strings"
"time"
@@ -289,7 +291,23 @@ func build(cmd *cobra.Command, args []string) error {
}
report, err := registry.ImageEngine().Build(registry.GetContext(), containerFiles, *apiBuildOpts)
+
if err != nil {
+ exitCode := buildahCLI.ExecErrorCodeGeneric
+ if registry.IsRemote() {
+ // errors from server does not contain ExitCode
+ // so parse exit code from error message
+ remoteExitCode, parseErr := utils.ExitCodeFromBuildError(fmt.Sprint(errors.Cause(err)))
+ if parseErr == nil {
+ exitCode = remoteExitCode
+ }
+ }
+
+ if ee, ok := (errors.Cause(err)).(*exec.ExitError); ok {
+ exitCode = ee.ExitCode()
+ }
+
+ registry.SetExitCode(exitCode)
return err
}