diff --git a/utils/sysfs/sysfs.go b/utils/sysfs/sysfs.go index becc4afc475..25c5ba1239c 100644 --- a/utils/sysfs/sysfs.go +++ b/utils/sysfs/sysfs.go @@ -22,7 +22,6 @@ import ( "os" "path" "path/filepath" - "regexp" "strconv" "strings" @@ -341,7 +340,7 @@ func (fs *realSysFs) IsCPUOnline(dir string) bool { if err != nil { pathErr, ok := err.(*os.PathError) if ok { - if errors.Is(pathErr.Unwrap(), os.ErrNotExist) && isZeroCPU(dir) { + if errors.Is(pathErr.Unwrap(), os.ErrNotExist) { return true } } @@ -352,8 +351,3 @@ func (fs *realSysFs) IsCPUOnline(dir string) bool { return len(trimmed) == 1 && trimmed[0] == 49 } -func isZeroCPU(dir string) bool { - regex := regexp.MustCompile("cpu([0-9]*)") - matches := regex.FindStringSubmatch(dir) - return len(matches) == 2 && matches[1] == "0" -} diff --git a/utils/sysfs/sysfs_test.go b/utils/sysfs/sysfs_test.go index a14129df91c..6f9e862d62a 100644 --- a/utils/sysfs/sysfs_test.go +++ b/utils/sysfs/sysfs_test.go @@ -139,5 +139,5 @@ func TestIsCPUOnlineNoFileAndCPU0MustBeOnline(t *testing.T) { assert.True(t, online) online = sysFs.IsCPUOnline("./testdata/missing_online/node0/cpu33") - assert.False(t, online) + assert.True(t, online) }