diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2020-04-17 14:43:21 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-17 14:43:21 -0400 |
commit | ba289dcd79e3a2b5ec5dc02bd8adb84c93bef577 (patch) | |
tree | 977792d0b732bb67f9270d34e30bfac3cb5aab73 | |
parent | a5884c07dfb092eab88cf153238e714910388a06 (diff) | |
parent | 44a8cf867665927111fe9ea03711c8fabfc7d4a2 (diff) | |
download | podman-ba289dcd79e3a2b5ec5dc02bd8adb84c93bef577.tar.gz podman-ba289dcd79e3a2b5ec5dc02bd8adb84c93bef577.tar.bz2 podman-ba289dcd79e3a2b5ec5dc02bd8adb84c93bef577.zip |
Merge pull request #5868 from baude/v2t2
Fixes for system tests
-rw-r--r-- | cmd/podman/containers/run.go | 1 | ||||
-rw-r--r-- | cmd/podman/images/list.go | 12 | ||||
-rw-r--r-- | cmd/podman/inspect.go | 13 | ||||
-rw-r--r-- | pkg/api/handlers/libpod/images.go | 2 | ||||
-rw-r--r-- | pkg/api/handlers/types.go | 2 | ||||
-rw-r--r-- | pkg/domain/entities/images.go | 4 | ||||
-rw-r--r-- | pkg/domain/infra/abi/containers.go | 10 | ||||
-rw-r--r-- | pkg/domain/infra/abi/images_list.go | 2 | ||||
-rw-r--r-- | test/system/005-info.bats | 14 |
9 files changed, 38 insertions, 22 deletions
diff --git a/cmd/podman/containers/run.go b/cmd/podman/containers/run.go index 91edb6bda..151f71885 100644 --- a/cmd/podman/containers/run.go +++ b/cmd/podman/containers/run.go @@ -136,6 +136,7 @@ func run(cmd *cobra.Command, args []string) error { } if cliVals.Detach { fmt.Println(report.Id) + return nil } if runRmi { _, err := registry.ImageEngine().Delete(registry.GetContext(), []string{args[0]}, entities.ImageDeleteOptions{}) diff --git a/cmd/podman/images/list.go b/cmd/podman/images/list.go index 366dfc4ba..63ddc5d56 100644 --- a/cmd/podman/images/list.go +++ b/cmd/podman/images/list.go @@ -112,14 +112,16 @@ func images(cmd *cobra.Command, args []string) error { func writeJSON(imageS []*entities.ImageSummary) error { type image struct { entities.ImageSummary - Created string + Created string + CreatedAt string } imgs := make([]image, 0, len(imageS)) for _, e := range imageS { var h image h.ImageSummary = *e - h.Created = time.Unix(e.Created, 0).Format(time.RFC3339) + h.Created = units.HumanDuration(time.Since(e.Created)) + " ago" + h.CreatedAt = e.Created.Format(time.RFC3339Nano) h.RepoTags = nil imgs = append(imgs, h) @@ -196,7 +198,7 @@ func sortFunc(key string, data []*entities.ImageSummary) func(i, j int) bool { default: // case "created": return func(i, j int) bool { - return data[i].Created >= data[j].Created + return data[i].Created.After(data[j].Created) } } } @@ -255,11 +257,11 @@ func (i imageReporter) ID() string { if !listFlag.noTrunc && len(i.ImageSummary.ID) >= 12 { return i.ImageSummary.ID[0:12] } - return i.ImageSummary.ID + return "sha256:" + i.ImageSummary.ID } func (i imageReporter) Created() string { - return units.HumanDuration(time.Since(time.Unix(i.ImageSummary.Created, 0))) + " ago" + return units.HumanDuration(time.Since(i.ImageSummary.Created)) + " ago" } func (i imageReporter) Size() string { diff --git a/cmd/podman/inspect.go b/cmd/podman/inspect.go index 0393303e8..e67bc326b 100644 --- a/cmd/podman/inspect.go +++ b/cmd/podman/inspect.go @@ -4,6 +4,7 @@ import ( "context" "fmt" + "github.com/containers/image/v5/docker/reference" "github.com/containers/libpod/cmd/podman/common" "github.com/containers/libpod/cmd/podman/containers" "github.com/containers/libpod/cmd/podman/images" @@ -37,12 +38,14 @@ func init() { } func inspect(cmd *cobra.Command, args []string) error { - if found, err := registry.ImageEngine().Exists(context.Background(), args[0]); err != nil { - return err - } else if found.Value { - return images.Inspect(cmd, args, inspectOpts) + // First check if the input is even valid for an image + if _, err := reference.Parse(args[0]); err == nil { + if found, err := registry.ImageEngine().Exists(context.Background(), args[0]); err != nil { + return err + } else if found.Value { + return images.Inspect(cmd, args, inspectOpts) + } } - if found, err := registry.ContainerEngine().ContainerExists(context.Background(), args[0]); err != nil { return err } else if found.Value { diff --git a/pkg/api/handlers/libpod/images.go b/pkg/api/handlers/libpod/images.go index a42d06205..284b33637 100644 --- a/pkg/api/handlers/libpod/images.go +++ b/pkg/api/handlers/libpod/images.go @@ -111,7 +111,7 @@ func GetImages(w http.ResponseWriter, r *http.Request) { return } // libpod has additional fields that we need to populate. - is.Created = img.Created().Unix() + is.Created = img.Created() is.ReadOnly = img.IsReadOnly() summaries[j] = is } diff --git a/pkg/api/handlers/types.go b/pkg/api/handlers/types.go index f402da064..4c081cf85 100644 --- a/pkg/api/handlers/types.go +++ b/pkg/api/handlers/types.go @@ -262,7 +262,7 @@ func ImageToImageSummary(l *libpodImage.Image) (*entities.ImageSummary, error) { ID: l.ID(), ParentId: l.Parent, RepoTags: repoTags, - Created: l.Created().Unix(), + Created: l.Created(), Size: int64(*size), SharedSize: 0, VirtualSize: l.VirtualSize, diff --git a/pkg/domain/entities/images.go b/pkg/domain/entities/images.go index 78ebb8805..3a6d159e4 100644 --- a/pkg/domain/entities/images.go +++ b/pkg/domain/entities/images.go @@ -50,10 +50,10 @@ func (i *Image) Id() string { } type ImageSummary struct { - ID string `json:"Id"` + ID string ParentId string `json:",omitempty"` RepoTags []string `json:",omitempty"` - Created int64 `json:",omitempty"` + Created time.Time `json:",omitempty"` Size int64 `json:",omitempty"` SharedSize int `json:",omitempty"` VirtualSize int64 `json:",omitempty"` diff --git a/pkg/domain/infra/abi/containers.go b/pkg/domain/infra/abi/containers.go index c9df72f2d..50003dbe2 100644 --- a/pkg/domain/infra/abi/containers.go +++ b/pkg/domain/infra/abi/containers.go @@ -736,6 +736,16 @@ func (ic *ContainerEngine) ContainerRun(ctx context.Context, opts entities.Conta } else { report.ExitCode = int(ecode) } + if opts.Rm { + if err := ic.Libpod.RemoveContainer(ctx, ctr, false, true); err != nil { + if errors.Cause(err) == define.ErrNoSuchCtr || + errors.Cause(err) == define.ErrCtrRemoved { + logrus.Warnf("Container %s does not exist: %v", ctr.ID(), err) + } else { + logrus.Errorf("Error removing container %s: %v", ctr.ID(), err) + } + } + } return &report, nil } diff --git a/pkg/domain/infra/abi/images_list.go b/pkg/domain/infra/abi/images_list.go index 2f4020374..68b961cb6 100644 --- a/pkg/domain/infra/abi/images_list.go +++ b/pkg/domain/infra/abi/images_list.go @@ -54,7 +54,7 @@ func (ir *ImageEngine) List(ctx context.Context, opts entities.ImageListOptions) ID: img.ID(), ConfigDigest: string(img.ConfigDigest), - Created: img.Created().Unix(), + Created: img.Created(), Dangling: img.Dangling(), Digest: string(img.Digest()), Digests: digests, diff --git a/test/system/005-info.bats b/test/system/005-info.bats index c53ba8125..3c06103e8 100644 --- a/test/system/005-info.bats +++ b/test/system/005-info.bats @@ -8,19 +8,19 @@ load helpers run_podman info expected_keys=" -buildahVersion: *[0-9.]\\\+ +buildahversion: *[0-9.]\\\+ conmon:\\\s\\\+package: distribution: -ociRuntime:\\\s\\\+name: +ociruntime:\\\s\\\+name: os: rootless: registries: store: -graphDriverName: -graphRoot: -graphStatus: -imageStore:\\\s\\\+number: 1 -runRoot: +graphdrivername: +graphroot: +graphstatus: +imagestore:\\\s\\\+number: 1 +runroot: " while read expect; do is "$output" ".*$expect" "output includes '$expect'" |