Bug #3525
closedforeman-report_v2 raises an exception: no block given
Description
When our Puppetmaster attempts to use the latest version of foreman-report_v2.rb.erb to send a report to Foreman 1.3, it generates this exception:
Oct 25 11:31:32 util-stage-001 puppet-master[19693]: Report processor failed: Could not send report to Foreman at https://foreman.foo.com//api/reports: no block given /usr/lib/ruby/site_ruby/1.8/puppet/util/autoload.rb:77:in `inject'/usr/lib/ruby/site_ruby/1.8/puppet/reports/foreman.rb:101:in `each'/usr/lib/ruby/site_ruby/1.8/puppet/reports/foreman.rb:101:in `inject'/usr/lib/ruby/site_ruby/1.8/puppet/reports/foreman.rb:101:in `metrics_to_hash'/usr/lib/ruby/site_ruby/1.8/puppet/reports/foreman.rb:72:in `generate_report'/usr/lib/ruby/site_ruby/1.8/puppet/reports/foreman.rb:59:in `process'/usr/lib/ruby/site_ruby/1.8/puppet/indirector/report/processor.rb:37:in `process'/usr/lib/ruby/site_ruby/1.8/puppet/indirector/report/processor.rb:55:in `processors'/usr/lib/ruby/site_ruby/1.8/puppet/indirector/report/processor.rb:53:in `each'/usr/lib/ruby/site_ruby/1.8/puppet/indirector/report/processor.rb:53:in `processors'/usr/lib/ruby/site_ruby/1.8/puppet/indirector/report/processor.rb:30:in `process'/usr/lib/ruby/s...
This is the section of code that causes the exception:
# special fix for false warning about skips # sometimes there are skip values, but there are no error messages, we ignore them. if report_status["skipped"] > 0 and ((report_status.values.inject(:+)) - report_status["skipped"] == report.logs.size) report_status["skipped"] = 0 end
If I comment out these three lines, the foreman-report_v2 script works fine, although it is probably not handling skips properly.
We are currently using Puppet v2.7.21 on the puppetmaster server, and version ce323b1 of foreman-report_v2.rb.erb
Updated by Dominic Cleal about 11 years ago
Do you know which version of Ruby your puppetmaster's using?
Updated by Mark Heily about 11 years ago
It's the stock version of Ruby in CentOS 5.
# ruby --version ruby 1.8.6 (2009-08-04 patchlevel 383) [x86_64-linux]
Updated by Dominic Cleal about 11 years ago
Ah, I suspected it was EL5. The stock version is actually 1.8.5 there.
If this is the only issue that's appeared, then fixing it should be OK for now. Unfortunately our CI tool here (Travis) doesn't support .5 or .6 on their platform, so we'll need to test by hand.