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

Refactor: handle no response(s) wout error logging #105

Merged
merged 10 commits into from
Dec 23, 2021

Conversation

kares
Copy link
Contributor

@kares kares commented Dec 15, 2021

What does this PR do?

Refactors response handling from SNMP client - in case of no response (nil) no error will happen and thus won't get logged.

Why is it important/What is the impact to the user?

Example: when a table operation gets no data the client returns nil, that leads to an error with result.merge nil, which is than logged and confusing the user ... the plugin continues to operate fine. A no response should not be considered a reason for logging an error.

Author's Checklist

  • unit test(s)

Logs

[ERROR] 2021-11-23 12:01:14.157 [[main]<snmp] snmp - error invoking table operation on OID: vEdge, ignoring {:exception=>#<TypeError: no implicit conversion of nil into Hash>, :backtrace=>["org/jruby/RubyHash.java:1902:in `merge!'", "org/jruby/RubyHash.java:1938:in `merge'", "/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-input-snmp-1.2.8/lib/logstash/inputs/snmp.rb:189:in `block in run'", "org/jruby/RubyArray.java:1820:in `each'", "/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-input-snmp-1.2.8/lib/logstash/inputs/snmp.rb:187:in `block in run'", "org/jruby/RubyArray.java:1820:in `each'", "/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-input-snmp-1.2.8/lib/logstash/inputs/snmp.rb:167:in `block in run'", "/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-input-snmp-1.2.8/lib/logstash/inputs/snmp.rb:327:in `every'", "/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-input-snmp-1.2.8/lib/logstash/inputs/snmp.rb:166:in `run'", "/usr/share/logstash/logstash-core/lib/logstash/java_pipeline.rb:405:in `inputworker'", "/usr/share/logstash/logstash-core/lib/logstash/java_pipeline.rb:396:in `block in start_input'"]}

@kares
Copy link
Contributor Author

kares commented Dec 15, 2021

CI 🔴 8.x failing on main as well

@kares kares marked this pull request as ready for review December 15, 2021 14:00
@kares kares requested a review from kaisecheng December 21, 2021 11:22
Copy link
Contributor

@kaisecheng kaisecheng left a comment

Choose a reason for hiding this comment

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

overall look good to me 🍰 Do you think it makes sense to add walk unit test?

@kares
Copy link
Contributor Author

kares commented Dec 23, 2021

overall look good to me cake Do you think it makes sense to add walk unit test?

well spotted, left those out in the hopes no one will notice 😉
added and also refactored those specs not to rely on multi-threading.

@kares kares requested a review from kaisecheng December 23, 2021 11:16
Copy link
Contributor

@kaisecheng kaisecheng left a comment

Choose a reason for hiding this comment

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

test cases cover the changes. Red ci is the same as main. LGTM 👍

@kares kares merged commit 763d312 into logstash-plugins:main Dec 23, 2021
@lsihar
Copy link

lsihar commented Oct 3, 2022

Hello, I tried to use this version of the input snmp plugin on the version 7.16.3 of the ELK stack but I'm still have invoking OIDs errors.
My test: On my Pipeline I put an input snmp with 2 inexistant hosts, no filters are selected.

{"level":"ERROR","loggerName":"logstash.inputs.snmp","timeMillis":1664799193645,"thread":"[index.2]<snmp","logEvent":{"message":"error invoking get operation, ignoring","host":"192.168.10.11","oids":["1.3.6.1.2.1.1.5.0","1.3.6.1.2.1.1.1.0","1.3.6.1.2.1.1.3.0"],"exception":{"metaClass":{"metaClass":{"metaClass":{"exception":"timeout sending snmp get request to target 192.168.10.12/161","backtrace":["/home/vagrant/logstash_archive/vendor/bundle/jruby/2.5.0/gems/logstash-input-snmp-1.3.1/lib/logstash/inputs/snmp/base_client.rb:39:in `get'","/home/vagrant/logstash_archive/vendor/bundle/jruby/2.5.0/gems/logstash-input-snmp-1.3.1/lib/logstash/inputs/snmp.rb:210:in `block in poll_clients'","org/jruby/RubyArray.java:1821:in `each'","/home/vagrant/logstash_archive/vendor/bundle/jruby/2.5.0/gems/logstash-input-snmp-1.3.1/lib/logstash/inputs/snmp.rb:202:in `poll_clients'","/home/vagrant/logstash_archive/vendor/bundle/jruby/2.5.0/gems/logstash-input-snmp-1.3.1/lib/logstash/inputs/snmp.rb:197:in `block in run'","/home/vagrant/logstash_archive/vendor/bundle/jruby/2.5.0/gems/logstash-input-snmp-1.3.1/lib/logstash/inputs/snmp.rb:380:in `every'","/home/vagrant/logstash_archive/vendor/bundle/jruby/2.5.0/gems/logstash-input-snmp-1.3.1/lib/logstash/inputs/snmp.rb:196:in `run'","/home/vagrant/logstash_archive/logstash-core/lib/logstash/java_pipeline.rb:418:in `inputworker'","/logstash_archive/logstash-core/lib/logstash/java_pipeline.rb:409:in `block in start_input'"]}}}}}}

Even so, I have the correct version of the plugin :

./bin/logstash-plugin list --verbose | grep -i snmp

OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.
logstash-input-snmp (1.3.1)
logstash-input-snmptrap (3.0.6)

Is it because of the version of the stack that I am using ? or something else ?

Thank you

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.

3 participants