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

fix(processors.snmp_lookup): Return empty tag-map on error to avoid panic #15466

Conversation

Hipska
Copy link
Contributor

@Hipska Hipska commented Jun 6, 2024

Summary

Returning a tagMap with empty rows but created set, makes sure the rebuild of the table will only happen after min_time_between_updates.

Before

Telegraf crashes:

2024-06-05T08:32:43Z E! [processors.snmp_lookup] Building table for "172.16.43.2" failed: performing bulk walk for field ifName: request timeout (after 3 retries)
Worker exits from a panic: runtime error: invalid memory address or nil pointer dereference
Stack trace: goroutine 160 [running]:
runtime/debug.Stack()
/usr/local/go/src/runtime/debug/stack.go:24 +0x5e
github.com/alitto/pond.defaultPanicHandler({0x70a8180, 0xdc68f90})
/go/pkg/mod/github.com/alitto/pond@v1.8.3/pond.go:26 +0x25
github.com/alitto/pond.(*WorkerPool).executeTask.func1()
/go/pkg/mod/github.com/alitto/pond@v1.8.3/pond.go:437 +0x4a
panic({0x70a8180?, 0xdc68f90?})
/usr/local/go/src/runtime/panic.go:770 +0x132
github.com/influxdata/telegraf/plugins/processors/snmp_lookup.(*backlog).resolve(0xc03b210180, {0xc0256de590, 0xb}, 0x0)
/go/src/github.com/influxdata/telegraf/plugins/processors/snmp_lookup/backlog.go:79 +0x26e
github.com/influxdata/telegraf/plugins/processors/snmp_lookup.(*store).enqueue.func1()
/go/src/github.com/influxdata/telegraf/plugins/processors/snmp_lookup/store.go:80 +0x96
github.com/alitto/pond.(*WorkerPool).executeTask(0xc03b220000, 0x0?, 0x0?)
/go/pkg/mod/github.com/alitto/pond@v1.8.3/pond.go:454 +0x6c
github.com/alitto/pond.worker({0x8cdbd10, 0xc03aee5400}, 0x0?, 0x0?, 0xc02f837980, 0xc03aee1ee0)
/go/pkg/mod/github.com/alitto/pond@v1.8.3/worker.go:32 +0xc2
created by github.com/alitto/pond.(*WorkerPool).maybeStartWorker in goroutine 1
/go/pkg/mod/github.com/alitto/pond@v1.8.3/pond.go:423 +0x133

After

Processor returns the metrics unmodified:

2024-06-06T07:46:20Z E! [processors.snmp_lookup] Building table for "172.16.43.2" failed: performing bulk walk for field ifName: request timeout (after 3 retries)
2024-06-06T07:46:20Z W! [processors.snmp_lookup] Cannot resolve metrics because index "123" not found for agent "172.16.43.2"!

Checklist

  • No AI generated code was used in this PR

Related issues

resolves #15465

@telegraf-tiger telegraf-tiger bot added fix pr to fix corresponding bug plugin/processor labels Jun 6, 2024
@telegraf-tiger
Copy link
Contributor

telegraf-tiger bot commented Jun 6, 2024

Copy link
Member

@srebhan srebhan left a comment

Choose a reason for hiding this comment

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

Awesome fix @Hipska! Thanks a lot!

@srebhan srebhan added area/snmp ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review. labels Jun 6, 2024
@srebhan srebhan changed the title fix(processors.snmp_lookup): Return empty tagMap instead of nil fix(processors.snmp_lookup): Return empty tag-map on error to avoid panic Jun 6, 2024
@powersj powersj merged commit 45e9ae4 into influxdata:master Jun 6, 2024
29 checks passed
@github-actions github-actions bot added this to the v1.31.0 milestone Jun 6, 2024
@Hipska Hipska deleted the fix/processors/15465_snmp_lookup_panic branch June 6, 2024 14:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/snmp fix pr to fix corresponding bug plugin/processor ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

processor.snmp_lookup panic when no response from device
4 participants