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:
Davanum Srinivas
2016-08-03 13:02:09 -04:00
parent 012eb941d6
commit 1fdcea28e5
3 changed files with 64 additions and 18 deletions

View File

@@ -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())
}