Closed raffraffraff closed 7 years ago
@raffraffraff @paulrqualtrics I've looked into this a little bit more and I think my alleged fix for 1.9 is broken for the same reason.
Comparing the arguments for Net::HTTPGenericRequest
on 1.9.1 vs 2.3.0, I see that 1.9.1 expects argument path
where as 2.3.0 takes uri_or_path
argument. If the uri_or_path
is not a URI
object, it is treated as the path.
I believe we can unconditionally pass the value of uri.path
to net_http_req_class(method).new
on both ruby 1.9 and 2.x, as the hostname, port and scheme are explicitly set when calling Net::HTTP.start
.
Fixes a regression in the sensu-handler.rb, which breaks calls to the sensu API in version 1.4.3.
Description
The regression was caused by a previous commit which fixed a bug in Ruby 1.9 [sensu-handler.rb, line 136: changed 'uri' to 'uri.to_s']. This fix commit simply wraps the
uri =
in anif RUBY_VERSION > 1.9
check before deciding which method to use.Motivation and Context
sensu-plugins 1.4.3 is currently broken on newer Ruby versions.
The issue this fixes is: https://github.com/sensu-plugins/sensu-plugin/issues/160
How Has This Been Tested?
I am running this fork in a test datacenter on 3x sensu servers, and it fixes the regression. I have not tested this on any older Ruby versions, but it's a simple 'if' statement.
Versions used in test: Ruby: 2.3.0 Sensu: 0.26.5 sensu-plugin: 1.4.3 (with this patch)
Types of changes
Checklist:
Known Caveats