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

Dont check for temperatures in /thermal_zone where mode=disabled #694

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Saumya40-codes
Copy link

@Saumya40-codes Saumya40-codes commented Jan 13, 2025

Relevant issue

Fixes: prometheus/node_exporter#2980

Current behaviour

  • node_exporter checks for the contents of temp file even when mode is disabled due to which in the case when temp file contains a non desired value the thermal_zone collector fails and no longer gives its related metrics

Proposed solution

  • Have an early exit and dont check rest if mode is set to disabled

Testing

  • replacing github.com/prometheus/procfs in node_exporter go.mod to local dev setup of procfs and comparing the results in both

cc: @discordianfish

Signed-off-by: Saumyacodes-40 <saumyabshah90@gmail.com>
return ClassThermalZoneStats{}, err
}

if strings.TrimSpace(modeContent) == "disabled" {
Copy link
Member

Choose a reason for hiding this comment

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

Typically we avoid making decisions like this in the library. Rather, we simply expose the mode as a raw attribute and allow the downstream consumer to decide what to do.

Copy link
Author

@Saumya40-codes Saumya40-codes Jan 17, 2025

Choose a reason for hiding this comment

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

Ohkk

Maybe thats something which can be handled from node exporter itself only?

here, as was stated in main issue, we check while reading the Zone temp and if the error turns out to be of type os.ErrInvalid then we can return an empty struct (and return an error when necessary (i.e. in the case of os.IsNotExist(err) && os.IsPermission(err)

Copy link
Member

Choose a reason for hiding this comment

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

Yes, we may need to refactor that error handling.

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.

Handle thermal_zone errors gracefully
2 participants