diff options
author | haircommander <pehunt@redhat.com> | 2018-07-27 13:58:50 -0400 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2018-08-23 18:16:28 +0000 |
commit | d5e690914dc78eca8664442e7677eb5004522bfd (patch) | |
tree | 3f7ed30e4302c871c16126a0032b8a3d51c46f98 /cmd/podman/ps.go | |
parent | 63dd200e7e47261454c7e55fed2ad972144e147f (diff) | |
download | podman-d5e690914dc78eca8664442e7677eb5004522bfd.tar.gz podman-d5e690914dc78eca8664442e7677eb5004522bfd.tar.bz2 podman-d5e690914dc78eca8664442e7677eb5004522bfd.zip |
Added option to share kernel namespaces in libpod and podman
A pause container is added to the pod if the user opts in. The default pause image and command can be overridden. Pause containers are ignored in ps unless the -a option is present. Pod inspect and pod ps show shared namespaces and pause container. A pause container can't be removed with podman rm, and a pod can be removed if it only has a pause container.
Signed-off-by: haircommander <pehunt@redhat.com>
Closes: #1187
Approved by: mheon
Diffstat (limited to 'cmd/podman/ps.go')
-rw-r--r-- | cmd/podman/ps.go | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/cmd/podman/ps.go b/cmd/podman/ps.go index 3b53fe6f1..332416d14 100644 --- a/cmd/podman/ps.go +++ b/cmd/podman/ps.go @@ -44,6 +44,7 @@ type psTemplateParams struct { User string UTS string Pod string + IsPause bool } // psJSONParams is used as a base structure for the psParams @@ -71,6 +72,7 @@ type psJSONParams struct { ContainerRunning bool `json:"ctrRunning"` Namespaces *shared.Namespace `json:"namespace,omitempty"` Pod string `json:"pod,omitempty"` + IsPause bool `json:"pause"` } // Type declaration and functions for sorting the PS output @@ -216,7 +218,7 @@ func psCmd(c *cli.Context) error { return errors.Errorf("too many arguments, ps takes no arguments") } - format := genPsFormat(c.String("format"), c.Bool("quiet"), c.Bool("size"), c.Bool("namespace"), c.Bool("pod")) + format := genPsFormat(c.String("format"), c.Bool("quiet"), c.Bool("size"), c.Bool("namespace"), c.Bool("pod"), c.Bool("all")) opts := shared.PsOptions{ All: c.Bool("all"), @@ -239,7 +241,8 @@ func psCmd(c *cli.Context) error { // only get running containers filterFuncs = append(filterFuncs, func(c *libpod.Container) bool { state, _ := c.State() - return state == libpod.ContainerStateRunning + // Don't return pause containers + return state == libpod.ContainerStateRunning && !c.IsPause() }) } @@ -417,7 +420,7 @@ func generateContainerFilterFuncs(filter, filterValue string, runtime *libpod.Ru } // generate the template based on conditions given -func genPsFormat(format string, quiet, size, namespace, pod bool) string { +func genPsFormat(format string, quiet, size, namespace, pod, pause bool) string { if format != "" { // "\t" from the command line is not being recognized as a tab // replacing the string "\t" to a tab character if the user passes in "\t" @@ -431,13 +434,16 @@ func genPsFormat(format string, quiet, size, namespace, pod bool) string { podappend = "{{.Pod}}\t" } if namespace { - return fmt.Sprintf("table {{.ID}}\t{{.Names}}\t%s{{.PID}}\t{{.Cgroup}}\t{{.IPC}}\t{{.MNT}}\t{{.NET}}\t{{.PIDNS}}\t{{.User}}\t{{.UTS}}\t", podappend) + return fmt.Sprintf("table {{.ID}}\t{{.Names}}\t%s{{.PID}}\t{{.Cgroup}}\t{{.IPC}}\t{{.MNT}}\t{{.NET}}\t{{.PIDNS}}\t{{.User}}\t{{.UTS}}", podappend) } format = "table {{.ID}}\t{{.Image}}\t{{.Command}}\t{{.Created}}\t{{.Status}}\t{{.Ports}}\t{{.Names}}\t" format += podappend if size { format += "{{.Size}}\t" } + if pause { + format += "{{.IsPause}}\t" + } return format } @@ -572,6 +578,7 @@ func getTemplateOutput(psParams []psJSONParams, opts shared.PsOptions) ([]psTemp Mounts: getMounts(psParam.Mounts, opts.NoTrunc), PID: psParam.PID, Pod: pod, + IsPause: psParam.IsPause, } if opts.Namespace { @@ -628,6 +635,7 @@ func getAndSortJSONParams(containers []*libpod.Container, opts shared.PsOptions) ContainerRunning: batchInfo.ConState == libpod.ContainerStateRunning, Namespaces: ns, Pod: ctr.PodID(), + IsPause: ctr.IsPause(), } psOutput = append(psOutput, params) |