-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Skip bad entries on interrupt input #4497
Conversation
@@ -62,7 +65,8 @@ func parseInterrupts(r io.Reader) ([]IRQ, error) { | |||
if i < len(irqvals) { | |||
irqval, err := strconv.ParseInt(irqvals[i], 10, 64) | |||
if err != nil { | |||
return irqs, fmt.Errorf("Unable to parse %q from %q: %s", irqvals[i], scanner.Text(), err) | |||
log.Printf("I! skipping interrupt field '%s': %s", irqvals[i], err.Error()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be hit every interval with the example /proc/interrupts
, so we don't want to log. However, we don't want to mask all errors either. I suggest checking if the line has at least cpucount
fields before this loop and if not skip the line.
It makes sense to keep this code here still though, only the case of not enough columns should be skipped.
for scanner.Scan() { | ||
fields := strings.Fields(scanner.Text()) | ||
if !strings.HasSuffix(fields[0], ":") { | ||
continue | ||
} | ||
if cpucount > len(fields) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was going to say we need to compare this against irqvals
since fields
includes the name of the irq, but then I noticed this line from the existing tests:
MIS: 0
So it is possible to have fewer fields than cpucount. Maybe we just continue with no error if the ParseInt call fails?
(cherry picked from commit 4fff507)
Resolves #4470