Skip to content

Commit

Permalink
Merge pull request #1 from Jeremy-boo/fix/cgroup2_path_not_found
Browse files Browse the repository at this point in the history
Fix the error "cgroup2 path not found"
  • Loading branch information
Jeremy-boo authored Dec 13, 2024
2 parents ce366eb + a453209 commit 71ac1e2
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions exec/executor_common_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,19 +163,22 @@ func execForHangAction(uid string, ctx context.Context, expModel *spec.ExpModel,
if isCgroupV2 {
g, err := cgroupsv2.PidGroupPath(int(pid))
if err != nil {
sprintf := fmt.Sprintf("loading cgroup2 for %d, err ", pid, err.Error())
sprintf := fmt.Sprintf("loading cgroup2 for %d, err %s", pid, err.Error())
return spec.ReturnFail(spec.OsCmdExecFailed, sprintf)
}
cg, err := cgroupsv2.LoadManager("/sys/fs/cgroup/", g)

cgPath := path.Join(cgroupRoot, g)
cg, err := cgroupsv2.LoadManager(cgroupRoot, cgPath)
if err != nil {
if err != cgroupsv2.ErrCgroupDeleted {
if cg, err = cgroupsv2.NewManager(cgroupRoot, cgPath, nil); err != nil {
sprintf := fmt.Sprintf("cgroups V2 new manager failed, %s", err.Error())
return spec.ReturnFail(spec.OsCmdExecFailed, sprintf)
}
} else {
sprintf := fmt.Sprintf("cgroups V2 load failed, %s", err.Error())
return spec.ReturnFail(spec.OsCmdExecFailed, sprintf)
}
if cg, err = cgroupsv2.NewManager("/sys/fs/cgroup", cgroupRoot, nil); err != nil {
sprintf := fmt.Sprintf("cgroups V2 new manager failed, %s", err.Error())
return spec.ReturnFail(spec.OsCmdExecFailed, sprintf)
}
}
if err := command.Start(); err != nil {
sprintf := fmt.Sprintf("command start failed, %s", err.Error())
Expand Down

0 comments on commit 71ac1e2

Please sign in to comment.