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

Fact rabbitmq_plugins_dirs can crash the puppet run #783

Closed
jistr opened this issue Mar 25, 2019 · 0 comments · Fixed by #784
Closed

Fact rabbitmq_plugins_dirs can crash the puppet run #783

jistr opened this issue Mar 25, 2019 · 0 comments · Fixed by #784
Labels
bug Something isn't working

Comments

@jistr
Copy link
Contributor

jistr commented Mar 25, 2019

Affected Puppet, Ruby, OS and module versions/distributions

  • Puppet: 5.5.6
  • Ruby: 2.5.3
  • rabbitmq_pluginsdirs_env = Facter::Core::Execution.execute("rabbitmqctl eval 'application:get_env(rabbit, plugins_dir).'")
    rabbitmq_plugins_dirs = %r{^\{ok\,\"(\/.+\/\w+)}.match(rabbitmq_pluginsdirs_env)[1]

How to reproduce (e.g Puppet code you use)

Use the module on a system which doesn't have rabbitmqctl present. E.g. when we only want to generate configs but not manage RabbitMQ on that host.

What are you seeing

"Error: Facter: error while resolving custom fact "rabbitmq_plugins_dirs": undefined method `[]' for nil:NilClass",

This happens because:

      rabbitmq_pluginsdirs_env = Facter::Core::Execution.execute("rabbitmqctl eval 'application:get_env(rabbit, plugins_dir).'")

returns nil, and then we try to access index on that nil with [1].

What behaviour did you expect instead

Ignore the absence of rabbitmqctl, return empty list for rabbitmq_plugins_dirs fact.

jistr added a commit to jistr/puppet-rabbitmq that referenced this issue Mar 25, 2019
Before trying to access the contents of a regexp match, see if the
match was successful. On machines without rabbitmqctl this match will
return nil.

Fixes: voxpupuli#783
jistr added a commit to jistr/puppet-rabbitmq that referenced this issue Mar 26, 2019
Before trying to access the contents of a regexp match, see if the
match was successful. On machines without rabbitmqctl this match will
return `nil`, so we can't index it with `[1]`. When that's the case,
the whole rabbitmq_plugins_dirs fact value will now be `nil`, instead
of throwing an exception.

Fixes: voxpupuli#783
jistr added a commit to jistr/puppet-rabbitmq that referenced this issue Mar 26, 2019
Before trying to access the contents of a regexp match, see if the
match was successful. On machines without rabbitmqctl this match will
return `nil`, so we can't index it with `[1]`. When that's the case,
the whole rabbitmq_plugins_dirs fact value will now be `nil`, instead
of throwing an exception.

Fixes: voxpupuli#783
jistr added a commit to jistr/puppet-rabbitmq that referenced this issue Mar 27, 2019
Before trying to access the contents of a regexp match, see if the
match was successful. On machines without rabbitmqctl this match will
return `nil`, so we can't index it with `[1]`. When that's the case,
the whole rabbitmq_plugins_dirs fact value will now be `nil`, instead
of throwing an exception.

Fixes: voxpupuli#783
jistr added a commit to jistr/puppet-rabbitmq that referenced this issue Mar 27, 2019
Before trying to access the contents of a regexp match, see if the
match was successful. On machines without rabbitmqctl this match will
return `nil`, so we can't index it with `[1]`. When that's the case,
the whole rabbitmq_plugins_dirs fact value will now be `nil`, instead
of throwing an exception.

Fixes: voxpupuli#783
@wyardley wyardley added the bug Something isn't working label Mar 27, 2019
cegeka-jenkins pushed a commit to cegeka/puppet-rabbitmq that referenced this issue Mar 26, 2021
Before trying to access the contents of a regexp match, see if the
match was successful. On machines without rabbitmqctl this match will
return `nil`, so we can't index it with `[1]`. When that's the case,
the whole rabbitmq_plugins_dirs fact value will now be `nil`, instead
of throwing an exception.

Fixes: voxpupuli#783
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants