Skip to content

fix(cpu): handle (null) in /sys/devices/system/cpu/isolated without error - #3860

Open
wangyusheng1985 wants to merge 1 commit into
prometheus:masterfrom
wangyusheng1985:fix/cpu-isolated-null-parsing-3152
Open

wangyusheng1985 wants to merge 1 commit into
prometheus:masterfrom
wangyusheng1985:fix/cpu-isolated-null-parsing-3152

Conversation

@wangyusheng1985

Copy link
Copy Markdown

On certain Linux kernels where no isolated CPUs are configured or the isolated cpumask pointer is null, /sys/devices/system/cpu/isolated outputs (null) (often formatted with leading spaces). When node_exporter starts up, this previously caused strconv.ParseUint / strconv.Atoi to fail with invalid syntax, panicking the node_exporter process.

Treat (null) as an empty isolated CPU list without returning an error. Add comprehensive unit tests covering empty, null, space-padded null, and standard ranges.

Closes #3152
Closes #3310

…rror

Signed-off-by: yusheng.wang <yusheng.wang@chaitin.com>
Comment thread collector/cpu_linux.go
}

isolcpus, err := sfs.IsolatedCPUs()
isolcpus, err := getIsolatedCPUs()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not re-implement procfs functions here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

(null)": invalid syntax the /sys/devices/system/cpu/isolated file is null ,Node-exporter fails to start

2 participants