diff options
-rw-r--r-- | cmd/podman/containers/stats.go | 27 | ||||
-rw-r--r-- | cmd/podman/images/load.go | 23 | ||||
-rw-r--r-- | cmd/podman/pods/stats.go | 11 | ||||
-rw-r--r-- | docs/source/markdown/podman-load.1.md | 9 | ||||
-rw-r--r-- | docs/source/markdown/podman-pod-stats.1.md | 23 | ||||
-rw-r--r-- | docs/source/markdown/podman-stats.1.md | 21 | ||||
-rw-r--r-- | libpod/container_internal.go | 17 | ||||
-rw-r--r-- | libpod/container_internal_linux.go | 2 | ||||
-rw-r--r-- | libpod/runtime_img.go | 7 | ||||
-rw-r--r-- | pkg/api/handlers/libpod/images.go | 15 | ||||
-rw-r--r-- | pkg/api/server/register_images.go | 4 | ||||
-rw-r--r-- | pkg/bindings/images/images.go | 11 | ||||
-rw-r--r-- | pkg/bindings/test/common_test.go | 2 | ||||
-rw-r--r-- | pkg/bindings/test/images_test.go | 14 | ||||
-rw-r--r-- | pkg/domain/entities/images.go | 2 | ||||
-rw-r--r-- | pkg/domain/entities/pods.go | 19 | ||||
-rw-r--r-- | pkg/domain/infra/abi/images.go | 14 | ||||
-rw-r--r-- | pkg/domain/infra/abi/pods_stats.go | 26 | ||||
-rw-r--r-- | pkg/domain/infra/tunnel/images.go | 7 | ||||
-rw-r--r-- | test/e2e/restart_test.go | 29 | ||||
-rw-r--r-- | test/system/120-load.bats | 28 |
21 files changed, 143 insertions, 168 deletions
diff --git a/cmd/podman/containers/stats.go b/cmd/podman/containers/stats.go index ca5c0fdb8..1a436aaef 100644 --- a/cmd/podman/containers/stats.go +++ b/cmd/podman/containers/stats.go @@ -147,13 +147,14 @@ func stats(cmd *cobra.Command, args []string) error { func outputStats(reports []define.ContainerStats) error { headers := report.Headers(define.ContainerStats{}, map[string]string{ - "ID": "ID", - "CPUPerc": "CPU %", - "MemUsage": "MEM USAGE / LIMIT", - "MemPerc": "MEM %", - "NetIO": "NET IO", - "BlockIO": "BLOCK IO", - "PIDS": "PIDS", + "ID": "ID", + "CPUPerc": "CPU %", + "MemUsage": "MEM USAGE / LIMIT", + "MemUsageBytes": "MEM USAGE / LIMIT", + "MemPerc": "MEM %", + "NetIO": "NET IO", + "BlockIO": "BLOCK IO", + "PIDS": "PIDS", }) if !statsOptions.NoReset { tm.Clear() @@ -222,10 +223,15 @@ func (s *containerStats) PIDS() string { } return fmt.Sprintf("%d", s.PIDs) } + func (s *containerStats) MemUsage() string { return combineHumanValues(s.ContainerStats.MemUsage, s.ContainerStats.MemLimit) } +func (s *containerStats) MemUsageBytes() string { + return combineBytesValues(s.ContainerStats.MemUsage, s.ContainerStats.MemLimit) +} + func floatToPercentString(f float64) string { strippedFloat, err := utils.RemoveScientificNotationFromFloat(f) if err != nil || strippedFloat == 0 { @@ -242,6 +248,13 @@ func combineHumanValues(a, b uint64) string { return fmt.Sprintf("%s / %s", units.HumanSize(float64(a)), units.HumanSize(float64(b))) } +func combineBytesValues(a, b uint64) string { + if a == 0 && b == 0 { + return "-- / --" + } + return fmt.Sprintf("%s / %s", units.BytesSize(float64(a)), units.BytesSize(float64(b))) +} + func outputJSON(stats []containerStats) error { type jstat struct { Id string `json:"id"` // nolint diff --git a/cmd/podman/images/load.go b/cmd/podman/images/load.go index a24f46781..59fc6f54c 100644 --- a/cmd/podman/images/load.go +++ b/cmd/podman/images/load.go @@ -9,9 +9,8 @@ import ( "strings" "github.com/containers/common/pkg/completion" - "github.com/containers/image/v5/docker/reference" - "github.com/containers/podman/v2/cmd/podman/parse" "github.com/containers/podman/v2/cmd/podman/registry" + "github.com/containers/podman/v2/cmd/podman/validate" "github.com/containers/podman/v2/pkg/domain/entities" "github.com/containers/podman/v2/pkg/util" "github.com/pkg/errors" @@ -22,11 +21,11 @@ import ( var ( loadDescription = "Loads an image from a locally stored archive (tar file) into container storage." loadCommand = &cobra.Command{ - Use: "load [options] [NAME[:TAG]]", + Use: "load [options]", Short: "Load image(s) from a tar archive", Long: loadDescription, RunE: load, - Args: cobra.MaximumNArgs(1), + Args: validate.NoArgs, ValidArgsFunction: completion.AutocompleteNone, } @@ -71,22 +70,8 @@ func loadFlags(cmd *cobra.Command) { } func load(cmd *cobra.Command, args []string) error { - if len(args) > 0 { - ref, err := reference.Parse(args[0]) - if err != nil { - return err - } - if t, ok := ref.(reference.Tagged); ok { - loadOpts.Tag = t.Tag() - } else { - loadOpts.Tag = "latest" - } - if r, ok := ref.(reference.Named); ok { - loadOpts.Name = r.Name() - } - } if len(loadOpts.Input) > 0 { - if err := parse.ValidateFileName(loadOpts.Input); err != nil { + if _, err := os.Stat(loadOpts.Input); err != nil { return err } } else { diff --git a/cmd/podman/pods/stats.go b/cmd/podman/pods/stats.go index 79e7cd8ed..5f79fa016 100644 --- a/cmd/podman/pods/stats.go +++ b/cmd/podman/pods/stats.go @@ -75,11 +75,12 @@ func stats(cmd *cobra.Command, args []string) error { doJSON := report.IsJSON(row) headers := report.Headers(entities.PodStatsReport{}, map[string]string{ - "CPU": "CPU %", - "MemUsage": "MEM USAGE/ LIMIT", - "MEM": "MEM %", - "NET IO": "NET IO", - "BlockIO": "BLOCK IO", + "CPU": "CPU %", + "MemUsage": "MEM USAGE/ LIMIT", + "MemUsageBytes": "MEM USAGE/ LIMIT", + "MEM": "MEM %", + "NET IO": "NET IO", + "BlockIO": "BLOCK IO", }) for ; ; time.Sleep(time.Second) { diff --git a/docs/source/markdown/podman-load.1.md b/docs/source/markdown/podman-load.1.md index dc2a632e5..3ff03e9e7 100644 --- a/docs/source/markdown/podman-load.1.md +++ b/docs/source/markdown/podman-load.1.md @@ -4,13 +4,12 @@ podman\-load - Load image(s) from a tar archive into container storage ## SYNOPSIS -**podman load** [*options*] [*name*[:*tag*]] +**podman load** [*options*] -**podman image load** [*options*] [*name*[:*tag*]] +**podman image load** [*options*] ## DESCRIPTION **podman load** loads an image from either an **oci-archive** or a **docker-archive** stored on the local machine into container storage. **podman load** reads from stdin by default or a file if the **input** option is set. -You can also specify a name for the image if the archive is of single image and load will tag an additional image with the name:tag. **podman load** is used for loading from the archive generated by **podman save**, that includes the image parent layers. To load the archive of container's filesystem created by **podman export**, use **podman import**. The local client further supports loading an **oci-dir** or a **docker-dir** as created with **podman save** (1). @@ -23,7 +22,7 @@ Note: `:` is a restricted character and cannot be part of the file name. **podman load [GLOBAL OPTIONS]** -**podman load [OPTIONS] NAME[:TAG]** +**podman load [OPTIONS]** ## OPTIONS @@ -78,7 +77,7 @@ Loaded image: registry.fedoraproject.org/fedora:latest ``` ## SEE ALSO -podman(1), podman-save(1), podman-tag(1) +podman(1), podman-save(1) ## HISTORY July 2017, Originally compiled by Urvashi Mohnani <umohnani@redhat.com> diff --git a/docs/source/markdown/podman-pod-stats.1.md b/docs/source/markdown/podman-pod-stats.1.md index b1b23cd06..4ef15fc20 100644 --- a/docs/source/markdown/podman-pod-stats.1.md +++ b/docs/source/markdown/podman-pod-stats.1.md @@ -35,17 +35,18 @@ Pretty-print container statistics to JSON or using a Go template Valid placeholders for the Go template are listed below: -| **Placeholder** | **Description** | -| --------------- | --------------- | -| .Pod | Pod ID | -| .CID | Container ID | -| .Name | Container Name | -| .CPU | CPU percentage | -| .MemUsage | Memory usage | -| .Mem | Memory percentage | -| .NetIO | Network IO | -| .BlockIO | Block IO | -| .PIDS | Number of PIDs | +| **Placeholder** | **Description** | +| --------------- | ------------------ | +| .Pod | Pod ID | +| .CID | Container ID | +| .Name | Container Name | +| .CPU | CPU percentage | +| .MemUsage | Memory usage | +| .MemUsageBytes | Memory usage (IEC) | +| .Mem | Memory percentage | +| .NetIO | Network IO | +| .BlockIO | Block IO | +| .PIDS | Number of PIDs | When using a GO template, you may precede the format with `table` to print headers. ## EXAMPLE diff --git a/docs/source/markdown/podman-stats.1.md b/docs/source/markdown/podman-stats.1.md index d5de8caf2..722027aae 100644 --- a/docs/source/markdown/podman-stats.1.md +++ b/docs/source/markdown/podman-stats.1.md @@ -45,16 +45,17 @@ Pretty-print container statistics to JSON or using a Go template Valid placeholders for the Go template are listed below: -| **Placeholder** | **Description** | -| --------------- | --------------- | -| .ID | Container ID | -| .Name | Container Name | -| .CPUPerc | CPU percentage | -| .MemUsage | Memory usage | -| .MemPerc | Memory percentage | -| .NetIO | Network IO | -| .BlockIO | Block IO | -| .PIDS | Number of PIDs | +| **Placeholder** | **Description** | +| --------------- | ------------------ | +| .ID | Container ID | +| .Name | Container Name | +| .CPUPerc | CPU percentage | +| .MemUsage | Memory usage | +| .MemUsageBytes | Memory usage (IEC) | +| .MemPerc | Memory percentage | +| .NetIO | Network IO | +| .BlockIO | Block IO | +| .PIDS | Number of PIDs | When using a GO template, you may precede the format with `table` to print headers. diff --git a/libpod/container_internal.go b/libpod/container_internal.go index c7548e0e5..f4cdb749f 100644 --- a/libpod/container_internal.go +++ b/libpod/container_internal.go @@ -1,6 +1,7 @@ package libpod import ( + "bufio" "bytes" "context" "fmt" @@ -1865,16 +1866,26 @@ func (c *Container) writeStringToStaticDir(filename, contents string) (string, e return destFileName, nil } -// appendStringToRundir appends the provided string to the runtimedir file -func (c *Container) appendStringToRundir(destFile, output string) (string, error) { +// appendStringToRunDir appends the provided string to the runtimedir file +func (c *Container) appendStringToRunDir(destFile, output string) (string, error) { destFileName := filepath.Join(c.state.RunDir, destFile) - f, err := os.OpenFile(destFileName, os.O_APPEND|os.O_WRONLY, 0600) + f, err := os.OpenFile(destFileName, os.O_APPEND|os.O_RDWR, 0600) if err != nil { return "", err } defer f.Close() + compareStr := strings.TrimRight(output, "\n") + scanner := bufio.NewScanner(f) + scanner.Split(bufio.ScanLines) + + for scanner.Scan() { + if strings.Compare(scanner.Text(), compareStr) == 0 { + return filepath.Join(c.state.RunDir, destFile), nil + } + } + if _, err := f.WriteString(output); err != nil { return "", errors.Wrapf(err, "unable to write %s", destFileName) } diff --git a/libpod/container_internal_linux.go b/libpod/container_internal_linux.go index 575047f95..ce2b52234 100644 --- a/libpod/container_internal_linux.go +++ b/libpod/container_internal_linux.go @@ -1742,7 +1742,7 @@ func (c *Container) generateHosts(path string) (string, error) { // FIXME. Path should be used by this function,but I am not sure what is correct; remove //lint // once this is fixed func (c *Container) appendHosts(path string, netCtr *Container) (string, error) { //nolint - return c.appendStringToRundir("hosts", netCtr.getHosts()) + return c.appendStringToRunDir("hosts", netCtr.getHosts()) } // getHosts finds the pertinent information for a container's host file in its config and state diff --git a/libpod/runtime_img.go b/libpod/runtime_img.go index 965333f77..2c5442bd2 100644 --- a/libpod/runtime_img.go +++ b/libpod/runtime_img.go @@ -279,6 +279,7 @@ func (r *Runtime) LoadImage(ctx context.Context, inputFile string, writer io.Wri if newImages, err := r.LoadAllImageFromArchive(ctx, writer, inputFile, signaturePolicy); err == nil { return newImages, nil } + return r.LoadImageFromSingleImageArchive(ctx, writer, inputFile, signaturePolicy) } @@ -293,7 +294,7 @@ func (r *Runtime) LoadAllImageFromArchive(ctx context.Context, writer io.Writer, // LoadImageFromSingleImageArchive load image from the archive of single image that inputFile points to. func (r *Runtime) LoadImageFromSingleImageArchive(ctx context.Context, writer io.Writer, inputFile, signaturePolicy string) (string, error) { - var err error + var saveErr error for _, referenceFn := range []func() (types.ImageReference, error){ func() (types.ImageReference, error) { return dockerarchive.ParseReference(inputFile) @@ -312,10 +313,12 @@ func (r *Runtime) LoadImageFromSingleImageArchive(ctx context.Context, writer io if err == nil && src != nil { if newImages, err := r.ImageRuntime().LoadFromArchiveReference(ctx, src, signaturePolicy, writer); err == nil { return getImageNames(newImages), nil + } else { + saveErr = err } } } - return "", errors.Wrapf(err, "error pulling image") + return "", errors.Wrapf(saveErr, "error pulling image") } func getImageNames(images []*image.Image) string { diff --git a/pkg/api/handlers/libpod/images.go b/pkg/api/handlers/libpod/images.go index b2b93de17..5b15527b7 100644 --- a/pkg/api/handlers/libpod/images.go +++ b/pkg/api/handlers/libpod/images.go @@ -353,20 +353,7 @@ func ImagesLoad(w http.ResponseWriter, r *http.Request) { utils.Error(w, "Something went wrong.", http.StatusInternalServerError, errors.Wrap(err, "unable to load image")) return } - split := strings.Split(loadedImage, ",") - newImage, err := runtime.ImageRuntime().NewFromLocal(split[0]) - if err != nil { - utils.InternalServerError(w, err) - return - } - // TODO this should go into libpod proper at some point. - if len(query.Reference) > 0 { - if err := newImage.TagImage(query.Reference); err != nil { - utils.InternalServerError(w, err) - return - } - } - utils.WriteResponse(w, http.StatusOK, entities.ImageLoadReport{Names: split}) + utils.WriteResponse(w, http.StatusOK, entities.ImageLoadReport{Names: strings.Split(loadedImage, ",")}) } func ImagesImport(w http.ResponseWriter, r *http.Request) { diff --git a/pkg/api/server/register_images.go b/pkg/api/server/register_images.go index 7e6de8783..8d0c0800b 100644 --- a/pkg/api/server/register_images.go +++ b/pkg/api/server/register_images.go @@ -797,10 +797,6 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error { // summary: Load image // description: Load an image (oci-archive or docker-archive) stream. // parameters: - // - in: query - // name: reference - // description: "Optional Name[:TAG] for the image" - // type: string // - in: formData // name: upload // description: tarball of container image diff --git a/pkg/bindings/images/images.go b/pkg/bindings/images/images.go index ecdd1f553..ae6962c8c 100644 --- a/pkg/bindings/images/images.go +++ b/pkg/bindings/images/images.go @@ -113,20 +113,13 @@ func History(ctx context.Context, nameOrID string, options *HistoryOptions) ([]* return history, response.Process(&history) } -func Load(ctx context.Context, r io.Reader, options *LoadOptions) (*entities.ImageLoadReport, error) { - if options == nil { - options = new(LoadOptions) - } +func Load(ctx context.Context, r io.Reader) (*entities.ImageLoadReport, error) { var report entities.ImageLoadReport conn, err := bindings.GetClient(ctx) if err != nil { return nil, err } - params, err := options.ToParams() - if err != nil { - return nil, err - } - response, err := conn.DoRequest(r, http.MethodPost, "/images/load", params, nil) + response, err := conn.DoRequest(r, http.MethodPost, "/images/load", nil, nil) if err != nil { return nil, err } diff --git a/pkg/bindings/test/common_test.go b/pkg/bindings/test/common_test.go index 232d7136f..c2b1347d2 100644 --- a/pkg/bindings/test/common_test.go +++ b/pkg/bindings/test/common_test.go @@ -182,7 +182,7 @@ func (b *bindingTest) RestoreImagesFromCache() { } } func (b *bindingTest) restoreImageFromCache(i testImage) { - p := b.runPodman([]string{"load", "-i", filepath.Join(ImageCacheDir, i.tarballName), i.name}) + p := b.runPodman([]string{"load", "-i", filepath.Join(ImageCacheDir, i.tarballName)}) p.Wait(45) } diff --git a/pkg/bindings/test/images_test.go b/pkg/bindings/test/images_test.go index c6b9c20f9..81959e813 100644 --- a/pkg/bindings/test/images_test.go +++ b/pkg/bindings/test/images_test.go @@ -219,7 +219,7 @@ var _ = Describe("Podman images", func() { f, err := os.Open(filepath.Join(ImageCacheDir, alpine.tarballName)) defer f.Close() Expect(err).To(BeNil()) - names, err := images.Load(bt.conn, f, nil) + names, err := images.Load(bt.conn, f) Expect(err).To(BeNil()) Expect(names.Names[0]).To(Equal(alpine.name)) exists, err = images.Exists(bt.conn, alpine.name) @@ -234,14 +234,9 @@ var _ = Describe("Podman images", func() { exists, err = images.Exists(bt.conn, alpine.name) Expect(err).To(BeNil()) Expect(exists).To(BeFalse()) - newName := "quay.io/newname:fizzle" - options := new(images.LoadOptions).WithReference(newName) - names, err = images.Load(bt.conn, f, options) + names, err = images.Load(bt.conn, f) Expect(err).To(BeNil()) Expect(names.Names[0]).To(Equal(alpine.name)) - exists, err = images.Exists(bt.conn, newName) - Expect(err).To(BeNil()) - Expect(exists).To(BeTrue()) // load with a bad repo name should trigger a 500 f, err = os.Open(filepath.Join(ImageCacheDir, alpine.tarballName)) @@ -251,11 +246,6 @@ var _ = Describe("Podman images", func() { exists, err = images.Exists(bt.conn, alpine.name) Expect(err).To(BeNil()) Expect(exists).To(BeFalse()) - options = new(images.LoadOptions).WithReference("quay.io/newName:fizzle") - _, err = images.Load(bt.conn, f, options) - Expect(err).ToNot(BeNil()) - code, _ := bindings.CheckResponseCode(err) - Expect(code).To(BeNumerically("==", http.StatusInternalServerError)) }) It("Export Image", func() { diff --git a/pkg/domain/entities/images.go b/pkg/domain/entities/images.go index d5f88502a..0805152c3 100644 --- a/pkg/domain/entities/images.go +++ b/pkg/domain/entities/images.go @@ -256,8 +256,6 @@ type ImageInspectReport struct { } type ImageLoadOptions struct { - Name string - Tag string Input string Quiet bool SignaturePolicy string diff --git a/pkg/domain/entities/pods.go b/pkg/domain/entities/pods.go index edb0af15a..32900d536 100644 --- a/pkg/domain/entities/pods.go +++ b/pkg/domain/entities/pods.go @@ -212,15 +212,16 @@ type PodStatsOptions struct { // PodStatsReport includes pod-resource statistics data. type PodStatsReport struct { - CPU string - MemUsage string - Mem string - NetIO string - BlockIO string - PIDS string - Pod string - CID string - Name string + CPU string + MemUsage string + MemUsageBytes string + Mem string + NetIO string + BlockIO string + PIDS string + Pod string + CID string + Name string } // ValidatePodStatsOptions validates the specified slice and options. Allows diff --git a/pkg/domain/infra/abi/images.go b/pkg/domain/infra/abi/images.go index 3487dc3f4..1c233d9d5 100644 --- a/pkg/domain/infra/abi/images.go +++ b/pkg/domain/infra/abi/images.go @@ -453,19 +453,7 @@ func (ir *ImageEngine) Load(ctx context.Context, opts entities.ImageLoadOptions) if err != nil { return nil, err } - names := strings.Split(name, ",") - if len(names) <= 1 { - newImage, err := ir.Libpod.ImageRuntime().NewFromLocal(name) - if err != nil { - return nil, errors.Wrap(err, "image loaded but no additional tags were created") - } - if len(opts.Name) > 0 { - if err := newImage.TagImage(fmt.Sprintf("%s:%s", opts.Name, opts.Tag)); err != nil { - return nil, errors.Wrapf(err, "error adding %q to image %q", opts.Name, newImage.InputName) - } - } - } - return &entities.ImageLoadReport{Names: names}, nil + return &entities.ImageLoadReport{Names: strings.Split(name, ",")}, nil } func (ir *ImageEngine) Import(ctx context.Context, opts entities.ImageImportOptions) (*entities.ImageImportReport, error) { diff --git a/pkg/domain/infra/abi/pods_stats.go b/pkg/domain/infra/abi/pods_stats.go index 16c10710a..29bcbe087 100644 --- a/pkg/domain/infra/abi/pods_stats.go +++ b/pkg/domain/infra/abi/pods_stats.go @@ -44,15 +44,16 @@ func (ic *ContainerEngine) podsToStatsReport(pods []*libpod.Pod) ([]*entities.Po podID := pods[i].ID()[:12] for j := range podStats { r := entities.PodStatsReport{ - CPU: floatToPercentString(podStats[j].CPU), - MemUsage: combineHumanValues(podStats[j].MemUsage, podStats[j].MemLimit), - Mem: floatToPercentString(podStats[j].MemPerc), - NetIO: combineHumanValues(podStats[j].NetInput, podStats[j].NetOutput), - BlockIO: combineHumanValues(podStats[j].BlockInput, podStats[j].BlockOutput), - PIDS: pidsToString(podStats[j].PIDs), - CID: podStats[j].ContainerID[:12], - Name: podStats[j].Name, - Pod: podID, + CPU: floatToPercentString(podStats[j].CPU), + MemUsage: combineHumanValues(podStats[j].MemUsage, podStats[j].MemLimit), + MemUsageBytes: combineBytesValues(podStats[j].MemUsage, podStats[j].MemLimit), + Mem: floatToPercentString(podStats[j].MemPerc), + NetIO: combineHumanValues(podStats[j].NetInput, podStats[j].NetOutput), + BlockIO: combineHumanValues(podStats[j].BlockInput, podStats[j].BlockOutput), + PIDS: pidsToString(podStats[j].PIDs), + CID: podStats[j].ContainerID[:12], + Name: podStats[j].Name, + Pod: podID, } reports = append(reports, &r) } @@ -68,6 +69,13 @@ func combineHumanValues(a, b uint64) string { return fmt.Sprintf("%s / %s", units.HumanSize(float64(a)), units.HumanSize(float64(b))) } +func combineBytesValues(a, b uint64) string { + if a == 0 && b == 0 { + return "-- / --" + } + return fmt.Sprintf("%s / %s", units.BytesSize(float64(a)), units.BytesSize(float64(b))) +} + func floatToPercentString(f float64) string { strippedFloat, err := utils.RemoveScientificNotationFromFloat(f) if err != nil || strippedFloat == 0 { diff --git a/pkg/domain/infra/tunnel/images.go b/pkg/domain/infra/tunnel/images.go index fba60235e..8ab832599 100644 --- a/pkg/domain/infra/tunnel/images.go +++ b/pkg/domain/infra/tunnel/images.go @@ -215,12 +215,7 @@ func (ir *ImageEngine) Load(ctx context.Context, opts entities.ImageLoadOptions) if fInfo.IsDir() { return nil, errors.Errorf("remote client supports archives only but %q is a directory", opts.Input) } - ref := opts.Name - if len(opts.Tag) > 0 { - ref += ":" + opts.Tag - } - options := new(images.LoadOptions).WithReference(ref) - return images.Load(ir.ClientCtx, f, options) + return images.Load(ir.ClientCtx, f) } func (ir *ImageEngine) Import(ctx context.Context, opts entities.ImageImportOptions) (*entities.ImageImportReport, error) { diff --git a/test/e2e/restart_test.go b/test/e2e/restart_test.go index 114bd481a..584ccd22b 100644 --- a/test/e2e/restart_test.go +++ b/test/e2e/restart_test.go @@ -196,4 +196,33 @@ var _ = Describe("Podman restart", func() { Expect(restartTime.OutputToStringArray()[0]).To(Equal(startTime.OutputToStringArray()[0])) Expect(restartTime.OutputToStringArray()[1]).To(Not(Equal(startTime.OutputToStringArray()[1]))) }) + + It("Podman restart a container in a pod and hosts shouln't duplicated", func() { + // Fixes: https://github.com/containers/podman/issues/8921 + + _, ec, _ := podmanTest.CreatePod("foobar99") + Expect(ec).To(Equal(0)) + + session := podmanTest.RunTopContainerInPod("host-restart-test", "foobar99") + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + testCmd := []string{"exec", "host-restart-test", "sh", "-c", "wc -l < /etc/hosts"} + + // before restart + beforeRestart := podmanTest.Podman(testCmd) + beforeRestart.WaitWithDefaultTimeout() + Expect(beforeRestart.ExitCode()).To(Equal(0)) + + session = podmanTest.Podman([]string{"restart", "host-restart-test"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + + afterRestart := podmanTest.Podman(testCmd) + afterRestart.WaitWithDefaultTimeout() + Expect(afterRestart.ExitCode()).To(Equal(0)) + + // line count should be equal + Expect(beforeRestart.OutputToString()).To(Equal(afterRestart.OutputToString())) + }) }) diff --git a/test/system/120-load.bats b/test/system/120-load.bats index 272e2ae93..902cd9f5e 100644 --- a/test/system/120-load.bats +++ b/test/system/120-load.bats @@ -59,15 +59,13 @@ verify_iid_and_name() { local new_tag=t1$(random_string 6 | tr A-Z a-z) run_podman rmi $fqin - new_fqin=localhost/$new_name:$new_tag - run_podman load -i $archive $new_fqin + run_podman load -i $archive run_podman images --format '{{.Repository}}:{{.Tag}}' --sort tag is "${lines[0]}" "$IMAGE" "image is preserved" is "${lines[1]}" "$fqin" "image is reloaded with old fqin" - is "${lines[2]}" "$new_fqin" "image is reloaded with new fqin too" # Clean up - run_podman rmi $fqin $new_fqin + run_podman rmi $fqin } @@ -118,28 +116,6 @@ verify_iid_and_name() { verify_iid_and_name $img_name } -@test "podman load - NAME and NAME:TAG arguments work" { - get_iid_and_name - run_podman save $iid -o $archive - run_podman rmi $iid - - # Load with just a name (note: names must be lower-case) - random_name=$(random_string 20 | tr A-Z a-z) - run_podman load -i $archive $random_name - verify_iid_and_name "localhost/$random_name:latest" - - # Load with NAME:TAG arg - run_podman rmi $iid - random_tag=$(random_string 10 | tr A-Z a-z) - run_podman load -i $archive $random_name:$random_tag - verify_iid_and_name "localhost/$random_name:$random_tag" - - # Cleanup: restore desired image name - run_podman tag $iid $img_name - run_podman rmi "$random_name:$random_tag" -} - - @test "podman load - will not read from tty" { if [ ! -t 0 ]; then skip "STDIN is not a tty" |