Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to validate windows-system-stats-monitor.json configuration: ProcPath /proc check failed #747

Closed
mmiranda96 opened this issue Apr 11, 2023 · 2 comments · Fixed by #748
Labels
kind/bug Categorizes issue or PR as related to a bug. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release.

Comments

@mmiranda96
Copy link
Contributor

I noticed this issue when I was running NPD on Windows: when trying to run systemstatsmonitor, I get the following failure:

Failed to validate C:\node-problem-detector\config\windows-system-stats-monitor.json configuration [BIG JSON]: ProcPath /proc check failed: CreateFile /proc: The system cannot find the file specified.

After digging for a while, I found that this failure comes from

if _, err := os.Stat(ssc.ProcPath); err != nil {

It seems that we try to check the proc file on all platforms, and this is a problem because it doesn't apply for Windows.

This change was introduced in #594.

There are a couple of fixes I can think of:

  • Entirely removing the check: simplest fix, could cause an issue if the user provides a wrong directory.
  • Disabling the default /proc value (
    ssc.ProcPath = defaultProcPath
    ) and skipping the check if it's empty: will fail if user doesn't explicitly provide a directory.
  • Defining a specific value to skip validation (something like "undefined"): depending on a magic string is not always a good idea, and this value is kind of arbitrary.
  • Splitting validation logic between Windows and Linux: requires splitting logic but is the cleanest option.
@mmiranda96
Copy link
Contributor Author

/kind bug
/priority important-soon
/cc @CoderSherlock

@k8s-ci-robot k8s-ci-robot added kind/bug Categorizes issue or PR as related to a bug. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. labels Apr 11, 2023
@samuelkarp
Copy link
Member

Disabling the default /proc value

We can also conditionally have a default value based on the operating system. This can be done by a conditional with runtime.GOOS or by moving the declaration out to two separate files (a config_linux.go and a config_windows.go).

if runtime.GOOS == "linux" && ssc.ProcPath == "" {
	ssc.ProcPath = defaultProcPath
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants