Fix runc ps issue
After #1009, we don't always set `cgroup.Paths`, so `getCgroupPath()` will return wrong cgroup path because it'll take current process's cgroup as the parent, which would be wrong when we try to find the cgroup path in `runc ps` and `runc kill`. Fix it by using `m.GetPath()` to get the true cgroup paths. Reported-by: Yang Shukui <yangshukui@huawei.com> Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
This commit is contained in:
parent
37f1747aec
commit
da7bac1c90
|
@ -246,28 +246,13 @@ func (m *Manager) Freeze(state configs.FreezerState) error {
|
|||
}
|
||||
|
||||
func (m *Manager) GetPids() ([]int, error) {
|
||||
dir, err := getCgroupPath(m.Cgroups)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return cgroups.GetPids(dir)
|
||||
paths := m.GetPaths()
|
||||
return cgroups.GetPids(paths["devices"])
|
||||
}
|
||||
|
||||
func (m *Manager) GetAllPids() ([]int, error) {
|
||||
dir, err := getCgroupPath(m.Cgroups)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return cgroups.GetAllPids(dir)
|
||||
}
|
||||
|
||||
func getCgroupPath(c *configs.Cgroup) (string, error) {
|
||||
d, err := getCgroupData(c, 0)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return d.path("devices")
|
||||
paths := m.GetPaths()
|
||||
return cgroups.GetAllPids(paths["devices"])
|
||||
}
|
||||
|
||||
func getCgroupData(c *configs.Cgroup, pid int) (*cgroupData, error) {
|
||||
|
|
Loading…
Reference in New Issue