summaryrefslogtreecommitdiff
path: root/cmd/podman
diff options
context:
space:
mode:
authorGiuseppe Scrivano <gscrivan@redhat.com>2018-08-29 10:02:15 +0200
committerAtomic Bot <atomic-devel@projectatomic.io>2018-08-29 16:25:20 +0000
commit2ed79f6315a35a76b405f62aa85088a5b9bd9af4 (patch)
tree9342616cae1cabe1e9ce75b962ff3d6538a7ba2d /cmd/podman
parent1789242933ddbc3e4a29662f5218b5b94ee30863 (diff)
downloadpodman-2ed79f6315a35a76b405f62aa85088a5b9bd9af4.tar.gz
podman-2ed79f6315a35a76b405f62aa85088a5b9bd9af4.tar.bz2
podman-2ed79f6315a35a76b405f62aa85088a5b9bd9af4.zip
rootless: fix top
join the user namespace used to create the container so that psgo can work in the same way as with root containers. Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com> Closes: #1371 Approved by: rhatdan
Diffstat (limited to 'cmd/podman')
-rw-r--r--cmd/podman/main.go1
-rw-r--r--cmd/podman/top.go13
2 files changed, 14 insertions, 0 deletions
diff --git a/cmd/podman/main.go b/cmd/podman/main.go
index bd1cc8b95..06d9308e0 100644
--- a/cmd/podman/main.go
+++ b/cmd/podman/main.go
@@ -34,6 +34,7 @@ var cmdsNotRequiringRootless = map[string]bool{
"kill": true,
"search": true,
"stop": true,
+ "top": true,
}
func main() {
diff --git a/cmd/podman/top.go b/cmd/podman/top.go
index 43728893c..5517fe230 100644
--- a/cmd/podman/top.go
+++ b/cmd/podman/top.go
@@ -8,6 +8,7 @@ import (
"github.com/containers/libpod/cmd/podman/libpodruntime"
"github.com/containers/libpod/libpod"
+ "github.com/containers/libpod/pkg/rootless"
"github.com/pkg/errors"
"github.com/urfave/cli"
)
@@ -69,6 +70,7 @@ func topCmd(c *cli.Context) error {
return err
}
+ rootless.SetSkipStorageSetup(true)
runtime, err := libpodruntime.GetRuntime(c)
if err != nil {
return errors.Wrapf(err, "error creating libpod runtime")
@@ -96,6 +98,17 @@ func topCmd(c *cli.Context) error {
return errors.Errorf("top can only be used on running containers")
}
+ pid, err := container.PID()
+ if err != nil {
+ return err
+ }
+ became, ret, err := rootless.JoinNS(uint(pid))
+ if err != nil {
+ return err
+ }
+ if became {
+ os.Exit(ret)
+ }
psOutput, err := container.GetContainerPidInformation(descriptors)
if err != nil {
return err