summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pkg/domain/entities/container_ps.go6
-rw-r--r--pkg/ps/ps.go21
-rw-r--r--pkg/specgen/generate/pod_create.go6
-rw-r--r--test/e2e/events_test.go13
4 files changed, 37 insertions, 9 deletions
diff --git a/pkg/domain/entities/container_ps.go b/pkg/domain/entities/container_ps.go
index 7c255b0ea..58f231a2f 100644
--- a/pkg/domain/entities/container_ps.go
+++ b/pkg/domain/entities/container_ps.go
@@ -10,7 +10,7 @@ import (
"github.com/pkg/errors"
)
-// Listcontainer describes a container suitable for listing
+// ListContainer describes a container suitable for listing
type ListContainer struct {
// AutoRemove
AutoRemove bool
@@ -18,7 +18,7 @@ type ListContainer struct {
Command []string
// Container creation time
Created time.Time
- // Human readable container creation time.
+ // Human-readable container creation time.
CreatedAt string
// If container has exited/stopped
Exited bool
@@ -65,7 +65,7 @@ type ListContainer struct {
Status string
}
-// ListContainer Namespaces contains the identifiers of the container's Linux namespaces
+// ListContainerNamespaces contains the identifiers of the container's Linux namespaces
type ListContainerNamespaces struct {
// Mount namespace
MNT string `json:"Mnt,omitempty"`
diff --git a/pkg/ps/ps.go b/pkg/ps/ps.go
index 0f154c524..69ac9c215 100644
--- a/pkg/ps/ps.go
+++ b/pkg/ps/ps.go
@@ -15,6 +15,7 @@ import (
"github.com/containers/podman/v3/pkg/domain/filters"
psdefine "github.com/containers/podman/v3/pkg/ps/define"
"github.com/containers/storage"
+ "github.com/containers/storage/types"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
)
@@ -63,10 +64,14 @@ func GetContainerLists(runtime *libpod.Runtime, options entities.ContainerListOp
}
for _, con := range cons {
listCon, err := ListContainerBatch(runtime, con, options)
- if err != nil {
+ switch {
+ case errors.Cause(err) == define.ErrNoSuchCtr:
+ continue
+ case err != nil:
return nil, err
+ default:
+ pss = append(pss, listCon)
}
- pss = append(pss, listCon)
}
if options.All && options.External {
@@ -89,7 +94,7 @@ func GetContainerLists(runtime *libpod.Runtime, options entities.ContainerListOp
return pss, nil
}
-// GetExternalContainerLists returns list of external containers for e.g created by buildah
+// GetExternalContainerLists returns list of external containers for e.g. created by buildah
func GetExternalContainerLists(runtime *libpod.Runtime) ([]entities.ListContainer, error) {
var (
pss = []entities.ListContainer{}
@@ -102,15 +107,19 @@ func GetExternalContainerLists(runtime *libpod.Runtime) ([]entities.ListContaine
for _, con := range externCons {
listCon, err := ListStorageContainer(runtime, con)
- if err != nil {
+ switch {
+ case errors.Cause(err) == types.ErrLoadError:
+ continue
+ case err != nil:
return nil, err
+ default:
+ pss = append(pss, listCon)
}
- pss = append(pss, listCon)
}
return pss, nil
}
-// BatchContainerOp is used in ps to reduce performance hits by "batching"
+// ListContainerBatch is used in ps to reduce performance hits by "batching"
// locks.
func ListContainerBatch(rt *libpod.Runtime, ctr *libpod.Container, opts entities.ContainerListOptions) (entities.ListContainer, error) {
var (
diff --git a/pkg/specgen/generate/pod_create.go b/pkg/specgen/generate/pod_create.go
index e523aef42..a4027eae7 100644
--- a/pkg/specgen/generate/pod_create.go
+++ b/pkg/specgen/generate/pod_create.go
@@ -59,6 +59,12 @@ func MakePod(p *entities.PodSpec, rt *libpod.Runtime) (*libpod.Pod, error) {
if err != nil {
return nil, err
}
+ } else {
+ // SavePod is used to save the pod state and trigger a create event even if infra is not created
+ err := rt.SavePod(pod)
+ if err != nil {
+ return nil, err
+ }
}
return pod, nil
}
diff --git a/test/e2e/events_test.go b/test/e2e/events_test.go
index 46ea10c56..ee0b8761a 100644
--- a/test/e2e/events_test.go
+++ b/test/e2e/events_test.go
@@ -199,4 +199,17 @@ var _ = Describe("Podman events", func() {
wg.Wait()
})
+
+ It("podman events pod creation", func() {
+ create := podmanTest.Podman([]string{"pod", "create", "--infra=false", "--name", "foobarpod"})
+ create.WaitWithDefaultTimeout()
+ Expect(create).Should(Exit(0))
+ id := create.OutputToString()
+ result := podmanTest.Podman([]string{"events", "--stream=false", "--filter", "pod=" + id})
+ result.WaitWithDefaultTimeout()
+ Expect(result).Should(Exit(0))
+ Expect(result.OutputToStringArray()).To(HaveLen(1))
+ Expect(result.OutputToString()).To(ContainSubstring("create"))
+ })
+
})