diff options
author | Giuseppe Scrivano <gscrivan@redhat.com> | 2021-11-24 10:34:47 +0100 |
---|---|---|
committer | Giuseppe Scrivano <gscrivan@redhat.com> | 2021-11-24 14:50:12 +0100 |
commit | a66f40b4df039e94572fa38c070207a435cfa466 (patch) | |
tree | 8c11e52437ef0571846b0c53a582ce0d2ff7fdb0 /libpod | |
parent | b25b330306782019d7aaf7618cd4598a9ae87250 (diff) | |
download | podman-a66f40b4df039e94572fa38c070207a435cfa466.tar.gz podman-a66f40b4df039e94572fa38c070207a435cfa466.tar.bz2 podman-a66f40b4df039e94572fa38c070207a435cfa466.zip |
libpod, inspect: export cgroup path
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Diffstat (limited to 'libpod')
-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 76a08ce30..83b643266 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 8e07cff81..677b39218 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"` Health HealthCheckResults `json:"Health,omitempty"` Checkpointed bool `json:"Checkpointed,omitempty"` + CgroupPath string `json:"CgroupPath,omitempty"` } // Healthcheck returns the HealthCheckResults. This is used for old podman compat |