mirror of
https://github.com/optim-enterprises-bv/kubernetes.git
synced 2025-11-25 19:05:13 +00:00
Remove kubelet dependency on pidof
Issue #26093 identified pidof as one of the dependencies of kublet which could be worked around. In this PR, we just look at /proc to construct the list of pids we need for a specified process instead of running "pidof" executable Related to #26093
This commit is contained in:
@@ -18,7 +18,12 @@ package procfs
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func verifyContainerName(procCgroupText, expectedName string, expectedErr bool, t *testing.T) {
|
||||
@@ -56,3 +61,12 @@ func TestContainerNameFromProcCgroup(t *testing.T) {
|
||||
procCgroupInvalid := "devices:docker/kubelet\ncpuacct:pkg/kubectl"
|
||||
verifyContainerName(procCgroupInvalid, "", true, t)
|
||||
}
|
||||
|
||||
func TestPidOf(t *testing.T) {
|
||||
if runtime.GOOS == "darwin" || runtime.GOOS == "windows" {
|
||||
t.Skipf("not supported on GOOS=%s", runtime.GOOS)
|
||||
}
|
||||
pids := PidOf(filepath.Base(os.Args[0]))
|
||||
assert.NotZero(t, pids)
|
||||
assert.Contains(t, pids, os.Getpid())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user