[TOB-K8S-027] Fix Incorrect isKernelPid check

isKernelPid should explicitly check the error returned from os.Readlink and return true
only if the error value is ENOENT. Without this fix, if Readlink
returned say ENAMETOOLONG or EACESS, we would still count the process as
a kernel process (which is not true).
This commit is contained in:
Davanum Srinivas 2019-08-07 11:19:09 -04:00
parent 1e962072f1
commit bd925d6611

View File

@ -888,7 +888,7 @@ func ensureSystemCgroups(rootCgroupPath string, manager *fs.Manager) error {
func isKernelPid(pid int) bool {
// Kernel threads have no associated executable.
_, err := os.Readlink(fmt.Sprintf("/proc/%d/exe", pid))
return err != nil
return err != nil && os.IsNotExist(err)
}
func (cm *containerManagerImpl) GetCapacity() v1.ResourceList {