voxpupuli / puppet-icinga2

Puppet module to manage Icinga 2
https://forge.puppet.com/icinga/icinga2
Apache License 2.0
61 stars 94 forks source link

Object#=~ is called on TrueClass #711

Closed deric closed 2 years ago

deric commented 2 years ago

I have many warnings in puppetserver logs that looks like this:

lib/puppet_x/icinga2/utils.rb:351: warning: deprecated Object#=~ is called on TrueClass; it always returns nil
lib/puppet_x/icinga2/utils.rb:186: warning: deprecated Object#=~ is called on TrueClass; it always returns nil
lib/puppet_x/icinga2/utils.rb:190: warning: deprecated Object#=~ is called on TrueClass; it always returns nil
lib/puppet_x/icinga2/utils.rb:193: warning: deprecated Object#=~ is called on TrueClass; it always returns nil
lib/puppet_x/icinga2/utils.rb:196: warning: deprecated Object#=~ is called on TrueClass; it always returns nil
lib/puppet_x/icinga2/utils.rb:199: warning: deprecated Object#=~ is called on TrueClass; it always returns nil
lib/puppet_x/icinga2/utils.rb:201: warning: deprecated Object#=~ is called on TrueClass; it always returns nil
lib/puppet_x/icinga2/utils.rb:204: warning: deprecated Object#=~ is called on TrueClass; it always returns nil

puppet-icinga2 version 3.3.1.

Is it possible to fix this?

One of the affected lines

      if row =~ %r{^-:(.*)$}m
        return Regexp.last_match(1)
      end

Probably we could check the row type at the beginning of the parse(row) function? It might slightly speed up parsing.

lbetz commented 2 years ago

Thx. I will look at it.

caniwi commented 2 years ago

I am getting this message as well. I am running icinga2 v3.4.0

lbetz commented 2 years ago

What kind of puppet version you're running on the server? My 7.13.1 doesn't report that in puppetserver.log with severity INFO.

deric commented 2 years ago

puppetserver in version 7.9.1-1bullseye

$ /opt/puppetlabs/puppet/bin/ruby -v
ruby 2.7.6p219 (2022-04-12 revision c9c2245c0a) [x86_64-linux]

@lbetz You're right it's not logged in puppetserver.log but systemd's journal: journalctl -e -u puppetserver

lbetz commented 2 years ago

Ok, I don't have these messages on my puppetserver 7.5.0 with ruby 2.7.3p183... mybe I have to update first. ... gotcha.

lbetz commented 2 years ago

Ok, either I have no idea how to fix it, or the cache is interfering.

lbetz commented 2 years ago

fixed in branch bug/711, please restart your puppetserver before testing it.

deric commented 2 years ago

@lbetz So far it looks good. Thanks for the quick fix!

lbetz commented 2 years ago

thx. 9 days ago, not sooo quick.

lbetz commented 2 years ago

Release will come at the weekend.