From 6d7e50891490682b86ab3f4a71cb6e8a7530c8b6 Mon Sep 17 00:00:00 2001 From: Ralf Haferkamp Date: Wed, 29 Jul 2020 10:56:00 +0200 Subject: Fix `podman image search` missing description `podman image search` returned wrong results for the image "Description" as it was mapped to the wrong field ("ID") in the search results. Signed-off-by: Ralf Haferkamp --- pkg/domain/infra/abi/images.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/domain/infra/abi/images.go b/pkg/domain/infra/abi/images.go index 3393275b8..9f594d728 100644 --- a/pkg/domain/infra/abi/images.go +++ b/pkg/domain/infra/abi/images.go @@ -402,7 +402,7 @@ func (ir *ImageEngine) Search(ctx context.Context, term string, opts entities.Im for i := range searchResults { reports[i].Index = searchResults[i].Index reports[i].Name = searchResults[i].Name - reports[i].Description = searchResults[i].Index + reports[i].Description = searchResults[i].Description reports[i].Stars = searchResults[i].Stars reports[i].Official = searchResults[i].Official reports[i].Automated = searchResults[i].Automated -- cgit v1.2.3-54-g00ecf From 8c6a5286934ebd0144b839223e9dd9a53e4f994a Mon Sep 17 00:00:00 2001 From: Daniel J Walsh Date: Tue, 28 Jul 2020 13:28:39 -0400 Subject: Fix building from http or '-' options When copying from a URL, podman will download and create a context directory in a temporary file. The problem was that this directory was being removed as soon as the function that created it was returned. Later the build code would look for content in the temporary directory and fail to find it, blowing up the build. By pulling the extraction code back into the build function, we keep the temporary directory around until the build completes. Signed-off-by: Daniel J Walsh --- cmd/podman/images/build.go | 52 ++++++++++++++++------------------------------ test/system/070-build.bats | 20 ++++++++++++++++++ 2 files changed, 38 insertions(+), 34 deletions(-) diff --git a/cmd/podman/images/build.go b/cmd/podman/images/build.go index 3ea74b4af..6cbffb3ae 100644 --- a/cmd/podman/images/build.go +++ b/cmd/podman/images/build.go @@ -138,36 +138,9 @@ func build(cmd *cobra.Command, args []string) error { return errors.New("cannot specify --squash, --squash-all and --layers options together") } - contextDir, containerFiles, err := extractContextAndFiles(args, buildOpts.File) - if err != nil { - return err - } - - ie, err := registry.NewImageEngine(cmd, args) - if err != nil { - return err - } - - apiBuildOpts, err := buildFlagsWrapperToOptions(cmd, contextDir, &buildOpts) - if err != nil { - return err - } - - _, err = ie.Build(registry.GetContext(), containerFiles, *apiBuildOpts) - return err -} - -// extractContextAndFiles parses args and files to extract a context directory -// and {Container,Docker}files. -// -// TODO: this was copied and altered from the v1 client which in turn was -// copied and altered from the Buildah code. Ideally, all of this code should -// be cleanly consolidated into a package that is shared between Buildah and -// Podman. -func extractContextAndFiles(args, files []string) (string, []string, error) { // Extract container files from the CLI (i.e., --file/-f) first. var containerFiles []string - for _, f := range files { + for _, f := range buildOpts.File { if f == "-" { containerFiles = append(containerFiles, "/dev/stdin") } else { @@ -181,7 +154,7 @@ func extractContextAndFiles(args, files []string) (string, []string, error) { // The context directory could be a URL. Try to handle that. tempDir, subDir, err := imagebuildah.TempDirForURL("", "buildah", args[0]) if err != nil { - return "", nil, errors.Wrapf(err, "error prepping temporary context directory") + return errors.Wrapf(err, "error prepping temporary context directory") } if tempDir != "" { // We had to download it to a temporary directory. @@ -196,7 +169,7 @@ func extractContextAndFiles(args, files []string) (string, []string, error) { // Nope, it was local. Use it as is. absDir, err := filepath.Abs(args[0]) if err != nil { - return "", nil, errors.Wrapf(err, "error determining path to directory %q", args[0]) + return errors.Wrapf(err, "error determining path to directory %q", args[0]) } contextDir = absDir } @@ -212,7 +185,7 @@ func extractContextAndFiles(args, files []string) (string, []string, error) { } absFile, err := filepath.Abs(containerFiles[i]) if err != nil { - return "", nil, errors.Wrapf(err, "error determining path to file %q", containerFiles[i]) + return errors.Wrapf(err, "error determining path to file %q", containerFiles[i]) } contextDir = filepath.Dir(absFile) break @@ -220,10 +193,10 @@ func extractContextAndFiles(args, files []string) (string, []string, error) { } if contextDir == "" { - return "", nil, errors.Errorf("no context directory and no Containerfile specified") + return errors.Errorf("no context directory and no Containerfile specified") } if !utils.IsDir(contextDir) { - return "", nil, errors.Errorf("context must be a directory: %q", contextDir) + return errors.Errorf("context must be a directory: %q", contextDir) } if len(containerFiles) == 0 { if utils.FileExists(filepath.Join(contextDir, "Containerfile")) { @@ -233,7 +206,18 @@ func extractContextAndFiles(args, files []string) (string, []string, error) { } } - return contextDir, containerFiles, nil + ie, err := registry.NewImageEngine(cmd, args) + if err != nil { + return err + } + + apiBuildOpts, err := buildFlagsWrapperToOptions(cmd, contextDir, &buildOpts) + if err != nil { + return err + } + + _, err = ie.Build(registry.GetContext(), containerFiles, *apiBuildOpts) + return err } // buildFlagsWrapperToOptions converts the local build flags to the build options used diff --git a/test/system/070-build.bats b/test/system/070-build.bats index fd4ce03fc..7d6660270 100644 --- a/test/system/070-build.bats +++ b/test/system/070-build.bats @@ -98,6 +98,26 @@ EOF is "$output" ".*error building at STEP .*: source can't be a URL for COPY" } +@test "podman build - stdin test" { + if is_remote && is_rootless; then + skip "unreliable with podman-remote and rootless; #2972" + fi + + # Random workdir, and multiple random strings to verify command & env + workdir=/$(random_string 10) + PODMAN_TIMEOUT=240 run_podman build -t build_test - << EOF +FROM $IMAGE +RUN mkdir $workdir +WORKDIR $workdir +RUN /bin/echo 'Test' +EOF + is "$output" ".*STEP 5: COMMIT" "COMMIT seen in log" + + run_podman run --rm build_test pwd + is "$output" "$workdir" "pwd command in container" + + run_podman rmi -f build_test +} function teardown() { # A timeout or other error in 'build' can leave behind stale images -- cgit v1.2.3-54-g00ecf From cae345331635ae57aff99327d5a9bfdfdf0c3a5b Mon Sep 17 00:00:00 2001 From: Akihiro Suda Date: Tue, 28 Jul 2020 18:17:13 +0900 Subject: compat/info.go: TrimPrefix(CGroupsVersion, "v") For compatibility with Docker: https://github.com/moby/moby/blob/846b7e24ba549a972a2672ffdd88b140da688736/api/swagger.yaml#L4528-L4534 Signed-off-by: Akihiro Suda --- pkg/api/handlers/compat/info.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/api/handlers/compat/info.go b/pkg/api/handlers/compat/info.go index 6c44393cc..c0033eab4 100644 --- a/pkg/api/handlers/compat/info.go +++ b/pkg/api/handlers/compat/info.go @@ -119,7 +119,7 @@ func GetInfo(w http.ResponseWriter, r *http.Request) { BuildahVersion: infoData.Host.BuildahVersion, CPURealtimePeriod: sysInfo.CPURealtimePeriod, CPURealtimeRuntime: sysInfo.CPURealtimeRuntime, - CgroupVersion: infoData.Host.CGroupsVersion, + CgroupVersion: strings.TrimPrefix(infoData.Host.CGroupsVersion, "v"), Rootless: rootless.IsRootless(), SwapFree: infoData.Host.SwapFree, SwapTotal: infoData.Host.SwapTotal, -- cgit v1.2.3-54-g00ecf From 806d0ab865ebc0747f86a26ab53c8183c251192a Mon Sep 17 00:00:00 2001 From: Akihiro Suda Date: Tue, 28 Jul 2020 16:35:05 +0900 Subject: Bump github.com/rootless-containers/rootlesskit from 0.9.5 to 0.10.0 Fix #7016 via https://github.com/rootless-containers/rootlesskit/pull/157 Signed-off-by: Akihiro Suda --- go.mod | 2 +- go.sum | 4 ++-- .../rootless-containers/rootlesskit/pkg/port/builtin/child/child.go | 2 ++ vendor/modules.txt | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index 736545116..50c991a38 100644 --- a/go.mod +++ b/go.mod @@ -47,7 +47,7 @@ require ( github.com/opentracing/opentracing-go v1.1.0 github.com/pkg/errors v0.9.1 github.com/pmezard/go-difflib v1.0.0 - github.com/rootless-containers/rootlesskit v0.9.5 + github.com/rootless-containers/rootlesskit v0.10.0 github.com/seccomp/containers-golang v0.5.0 github.com/sirupsen/logrus v1.6.0 github.com/spf13/cobra v0.0.7 diff --git a/go.sum b/go.sum index a86688f23..4a6d41158 100644 --- a/go.sum +++ b/go.sum @@ -385,8 +385,8 @@ github.com/prometheus/procfs v0.0.5 h1:3+auTFlqw+ZaQYJARz6ArODtkaIwtvBTx3N2NehQl github.com/prometheus/procfs v0.0.5/go.mod h1:4A/X28fw3Fc593LaREMrKMqOKvUAntwMDaekg4FpcdQ= github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= -github.com/rootless-containers/rootlesskit v0.9.5 h1:ygvFn6ms/14MlRQmMK8OSLKwwtHeRLFNblm+rOIndA0= -github.com/rootless-containers/rootlesskit v0.9.5/go.mod h1:OZQfuRPb+2MA1p+hmjHmSmDRv9SdTzlQ3taNA/0d7XM= +github.com/rootless-containers/rootlesskit v0.10.0 h1:62HHP8s8qYYcolEtAsuo4GU6qau6pWmcQ1Te+TZTFds= +github.com/rootless-containers/rootlesskit v0.10.0/go.mod h1:OZQfuRPb+2MA1p+hmjHmSmDRv9SdTzlQ3taNA/0d7XM= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/safchain/ethtool v0.0.0-20190326074333-42ed695e3de8 h1:2c1EFnZHIPCW8qKWgHMH/fX2PkSabFc5mrVzfUNdg5U= github.com/safchain/ethtool v0.0.0-20190326074333-42ed695e3de8/go.mod h1:Z0q5wiBQGYcxhMZ6gUqHn6pYNLypFAvaL3UvgZLR0U4= diff --git a/vendor/github.com/rootless-containers/rootlesskit/pkg/port/builtin/child/child.go b/vendor/github.com/rootless-containers/rootlesskit/pkg/port/builtin/child/child.go index 7cce235a6..112a926c3 100644 --- a/vendor/github.com/rootless-containers/rootlesskit/pkg/port/builtin/child/child.go +++ b/vendor/github.com/rootless-containers/rootlesskit/pkg/port/builtin/child/child.go @@ -119,11 +119,13 @@ func (d *childDriver) handleConnectRequest(c *net.UnixConn, req *msg.Request) er if err != nil { return err } + defer targetConnFile.Close() oob := unix.UnixRights(int(targetConnFile.Fd())) f, err := c.File() if err != nil { return err } + defer f.Close() for { err = unix.Sendmsg(int(f.Fd()), []byte("dummy"), oob, nil, 0) if err != unix.EINTR { diff --git a/vendor/modules.txt b/vendor/modules.txt index 0fdbbb67f..8a6b3cc2d 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -467,7 +467,7 @@ github.com/prometheus/common/model github.com/prometheus/procfs github.com/prometheus/procfs/internal/fs github.com/prometheus/procfs/internal/util -# github.com/rootless-containers/rootlesskit v0.9.5 +# github.com/rootless-containers/rootlesskit v0.10.0 github.com/rootless-containers/rootlesskit/pkg/msgutil github.com/rootless-containers/rootlesskit/pkg/port github.com/rootless-containers/rootlesskit/pkg/port/builtin -- cgit v1.2.3-54-g00ecf From c95d2856f86cd8d85284e0b5adf2dd221173c268 Mon Sep 17 00:00:00 2001 From: Daniel J Walsh Date: Mon, 20 Jul 2020 14:17:37 -0400 Subject: Switch references from libpod.conf to containers.conf Signed-off-by: Daniel J Walsh --- docs/source/markdown/podman.1.md | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/source/markdown/podman.1.md b/docs/source/markdown/podman.1.md index 790153ac2..01a054ff4 100644 --- a/docs/source/markdown/podman.1.md +++ b/docs/source/markdown/podman.1.md @@ -214,7 +214,6 @@ the exit codes follow the `chroot` standard, see below: ## FILES **containers.conf** (`/usr/share/containers/containers.conf`) - Podman has builtin defaults for command line options. These defaults can be overridden using the containers.conf configuration files. Distributions ship the `/usr/share/containers/containers.conf` file with their default settings. Administrators can override fields in this file by creating the `/etc/containers/containers.conf` file. Users can further modify defaults by creating the `$HOME/.config/containers/containers.conf` file. Podman merges its builtin defaults with the specified fields from these files, if they exist. Fields specified in the users file override the administrator's file, which overrides the distribution's file, which override the built-in defaults. -- cgit v1.2.3-54-g00ecf