From 174190132c1a7525eedf795ef8e9c78aaaeddaea Mon Sep 17 00:00:00 2001 From: Daniel J Walsh Date: Thu, 18 Jul 2024 06:37:17 -0400 Subject: [PATCH] More information for podman --remote build and running out of space. Users do not realize that the entire context directory is being copied into the podman machine when doing a podman --remote build. Adding information about the context directory might help them understand this. Improves: https://github.com/containers/podman/issues/23287 Signed-off-by: Daniel J Walsh --- pkg/api/handlers/compat/images_build.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/pkg/api/handlers/compat/images_build.go b/pkg/api/handlers/compat/images_build.go index 19a5338791..2f241d3727 100644 --- a/pkg/api/handlers/compat/images_build.go +++ b/pkg/api/handlers/compat/images_build.go @@ -11,6 +11,7 @@ import ( "path/filepath" "strconv" "strings" + "syscall" "time" "github.com/containers/buildah" @@ -33,6 +34,13 @@ import ( "github.com/sirupsen/logrus" ) +func genSpaceErr(err error) error { + if errors.Is(err, syscall.ENOSPC) { + return fmt.Errorf("context directory may be too large: %w", err) + } + return err +} + func BuildImage(w http.ResponseWriter, r *http.Request) { if hdr, found := r.Header["Content-Type"]; found && len(hdr) > 0 { contentType := hdr[0] @@ -73,7 +81,7 @@ func BuildImage(w http.ResponseWriter, r *http.Request) { contextDirectory, err := extractTarFile(anchorDir, r) if err != nil { - utils.InternalServerError(w, err) + utils.InternalServerError(w, genSpaceErr(err)) return } @@ -202,7 +210,7 @@ func BuildImage(w http.ResponseWriter, r *http.Request) { } tempDir, subDir, err := buildahDefine.TempDirForURL(anchorDir, "buildah", query.Remote) if err != nil { - utils.InternalServerError(w, err) + utils.InternalServerError(w, genSpaceErr(err)) return } if tempDir != "" {