diff options
author | Giuseppe Scrivano <gscrivan@redhat.com> | 2021-11-24 10:34:47 +0100 |
---|---|---|
committer | Matthew Heon <mheon@redhat.com> | 2021-12-06 15:25:07 -0500 |
commit | e3a50e760998cdcda6be6510cfa6f1ca93ba7633 (patch) | |
tree | 3afec4cf29f34416f08cafbc5c6e9c23f9df67c4 | |
parent | 5f9f3bbea02af17213ff57afbf30af670fc16a7a (diff) | |
download | podman-e3a50e760998cdcda6be6510cfa6f1ca93ba7633.tar.gz podman-e3a50e760998cdcda6be6510cfa6f1ca93ba7633.tar.bz2 podman-e3a50e760998cdcda6be6510cfa6f1ca93ba7633.zip |
libpod, inspect: export cgroup path
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
-rw-r--r-- | libpod/container_inspect.go | 11 | ||||
-rw-r--r-- | libpod/define/container_inspect.go | 1 |
2 files changed, 12 insertions, 0 deletions
diff --git a/libpod/container_inspect.go b/libpod/container_inspect.go index 9fcf13d53..e3b4b5bb2 100644 --- a/libpod/container_inspect.go +++ b/libpod/container_inspect.go @@ -97,6 +97,16 @@ func (c *Container) getContainerInspectData(size bool, driverData *define.Driver return nil, err } + cgroupPath, err := c.cGroupPath() + if err != nil { + // Handle the case where the container is not running or has no cgroup. + if errors.Is(err, define.ErrNoCgroups) || errors.Is(err, define.ErrCtrStopped) { + cgroupPath = "" + } else { + return nil, err + } + } + data := &define.InspectContainerData{ ID: config.ID, Created: config.CreatedTime, @@ -116,6 +126,7 @@ func (c *Container) getContainerInspectData(size bool, driverData *define.Driver StartedAt: runtimeInfo.StartedTime, FinishedAt: runtimeInfo.FinishedTime, Checkpointed: runtimeInfo.Checkpointed, + CgroupPath: cgroupPath, }, Image: config.RootfsImageID, ImageName: config.RootfsImageName, diff --git a/libpod/define/container_inspect.go b/libpod/define/container_inspect.go index 90703a807..7a5d4e572 100644 --- a/libpod/define/container_inspect.go +++ b/libpod/define/container_inspect.go @@ -204,6 +204,7 @@ type InspectContainerState struct { FinishedAt time.Time `json:"FinishedAt"` Healthcheck HealthCheckResults `json:"Healthcheck,omitempty"` Checkpointed bool `json:"Checkpointed,omitempty"` + CgroupPath string `json:"CgroupPath,omitempty"` } // HealthCheckResults describes the results/logs from a healthcheck |