Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix: Specifically cast passed in retries and timeout values to ints #104

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

Conversation

jrgns
Copy link

@jrgns jrgns commented Nov 16, 2021

Release notes

  • Fix issue where interval and retries can't be set using ENV variables. Using an ENV variable to set these values will result in the logs given below.

What does this PR do?

Specifically cast the retries and interval settings in the host array to integers. Since there's no validation on these values, if you set these values through ENV variables, they'll come through as strings.

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

Users will like to set these values through ENV variables.

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files (and/or docker env variables)
  • I have added tests that prove my fix is effective or that my feature works

How to test this PR locally

  • Use ENV variables to set the retries and interval values in the config:
input {
    snmp {
        hosts => [
            {host => "udp:127.0.0.1" community => "public" retries => '${RETRIES:2}' timeout => '${TIMEOUT:5000}' }

Related issues

None created

Logs

Pipeline error {:pipeline_id=>"inventory-input", :exception=>#<TypeError: cannot convert instance of class org.jruby.RubyString to int>, :backtrace=>[
	"/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-input-snmp-1.2.7/lib/logstash/inputs/snmp/client.rb:48:in `build_target'",
	"/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-input-snmp-1.2.7/lib/logstash/inputs/snmp/client.rb:25:in `initialize'",
	"/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-input-snmp-1.2.7/lib/logstash/inputs/snmp.rb:157:in `block in register'",
	"org/jruby/RubyArray.java:1809:in `each'",
	"/usr/share/logstash/vendor/bundle/jruby/2.5.0/gems/logstash-input-snmp-1.2.7/lib/logstash/inputs/snmp.rb:123:in `register'",
	"/usr/share/logstash/logstash-core/lib/logstash/java_pipeline.rb:228:in `block in register_plugins'",
	"org/jruby/RubyArray.java:1809:in `each'",
	"/usr/share/logstash/logstash-core/lib/logstash/java_pipeline.rb:227:in `register_plugins'",
	"/usr/share/logstash/logstash-core/lib/logstash/java_pipeline.rb:386:in `start_inputs'",
	"/usr/share/logstash/logstash-core/lib/logstash/java_pipeline.rb:311:in `start_workers'",
	"/usr/share/logstash/logstash-core/lib/logstash/java_pipeline.rb:185:in `run'",
	"/usr/share/logstash/logstash-core/lib/logstash/java_pipeline.rb:137:in `block in start'"
], "pipeline.sources"=>["/usr/share/logstash/pipeline/inventory.conf"], :thread=>"#<Thread:0x567073ec@/usr/share/logstash/logstash-core/lib/logstash/java_pipeline.rb:125 run>"}

@jrgns
Copy link
Author

jrgns commented Nov 16, 2021

Will provide tests as soon as I have a gap :)

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants