Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ListProcesses through PID when cgroup is not found in Linux #25198

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion drivers/shared/executor/executor_basic.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func withNetworkIsolation(f func() error, _ *drivers.NetworkIsolationSpec) error
func setCmdUser(*exec.Cmd, string) error { return nil }

func (e *UniversalExecutor) ListProcesses() set.Collection[int] {
return procstats.List(e.childCmd.Process.Pid)
return procstats.ListByPid(e.childCmd.Process.Pid)
}

func (e *UniversalExecutor) setSubCmdCgroup(*exec.Cmd, string) (func(), error) {
Expand Down
8 changes: 7 additions & 1 deletion drivers/shared/executor/executor_universal_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,13 @@ func (e *UniversalExecutor) setSubCmdCgroup(cmd *exec.Cmd, cgroup string) (func(
}

func (e *UniversalExecutor) ListProcesses() set.Collection[procstats.ProcessID] {
return procstats.List(e.command)
switch cgroupslib.GetMode() {
case cgroupslib.OFF:
// cgroup is unavailable, could possibly due to rootless nomad client
return procstats.ListByPid(e.childCmd.Process.Pid)
default:
return procstats.List(e.command)
}
}

func (e *UniversalExecutor) statCG(cgroup string) (int, func(), error) {
Expand Down
4 changes: 2 additions & 2 deletions drivers/shared/executor/procstats/list_default.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0

//go:build !linux && !windows
//go:build !windows

package procstats

Expand All @@ -15,7 +15,7 @@ import (
)

// List the process tree starting at the given executorPID
func List(executorPID int) set.Collection[ProcessID] {
func ListByPid(executorPID int) set.Collection[ProcessID] {
result := set.New[ProcessID](10)

ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
Expand Down