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

Add /proc/modules support #476

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

Conversation

Dentrax
Copy link
Contributor

@Dentrax Dentrax commented Nov 2, 2022

Signed-off-by: Furkan [email protected]

I have some use-cases for this implementation:

  • want to parse my /proc/interrupts file using procfs package (with go:linkname)
  • move module parsing logic from node-problem-detector to here

All tests passes.

Fixes #478

Taints: []string{},
}

if size, err := strconv.ParseUint(parts[1], 10, 64); err == nil {
Copy link
Member

Choose a reason for hiding this comment

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

Is it expected that the parsing might fail? If not, we should just abort here and return the error then silentely ignoring it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is it expected that the parsing might fail?

Yes, I think it's possible. Checking the error could also prevent from spec changes. (too low possibility, but still would be better than not checking instead.)

Copy link
Member

Choose a reason for hiding this comment

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

yeah but I don't like that we silentely ignore the error here. Why not return an error if err != nil?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why not return an error if err != nil?

That's because I noticed this err == nil pattern in some places. For example, arp:

procfs/arp.go

Line 98 in 0c4b3aa

if mac, err := net.ParseMAC(columns[3]); err == nil {
zoneinfo:
if err == nil {

I agree with you, returning an error would better. I can return an error if you want. Wdyt?

Copy link
Member

Choose a reason for hiding this comment

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

@SuperQ wdyt? But yeah I think returning an error would be better

Copy link
Member

Choose a reason for hiding this comment

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

Yes, returning the error would be better.

Copy link
Member

Choose a reason for hiding this comment

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

@Dentrax Can you change this so we can merge it?

proc_modules.go Outdated Show resolved Hide resolved
proc_modules_test.go Outdated Show resolved Hide resolved
proc_modules.go Show resolved Hide resolved
Taints: []string{},
}

if size, err := strconv.ParseUint(parts[1], 10, 64); err == nil {
Copy link
Member

Choose a reason for hiding this comment

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

Yes, returning the error would be better.

@rexagod
Copy link
Contributor

rexagod commented Mar 22, 2024

@Dentrax Just a nit, but can you add Fixes #478 to the description so that the original issue is closed when this gets in?

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.

Separate all parsing functions (or make public)
4 participants