waveclaw / puppet-subscription_manager

Handle Client Registration to RedHat Satellite 6 or Katello
https://rhn.redhat.com
Other
6 stars 34 forks source link

Fix provider prefetching to handle resources not being present #79

Closed treydock closed 5 years ago

treydock commented 5 years ago

I defined rhel-7-server-eus-rpms as absent and it's not a repo available to my satellite content view so ended up having no provider during prefetch so without this change the provider was getting set to nil. The line numbers won't match up in backtrace because I added lots of debug printing but errors are gone with this fix.

Error: Failed to apply catalog: undefined method `intern' for nil:NilClass
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/type.rb:1798:in `provider'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/type.rb:2011:in `provider='
/opt/puppetlabs/puppet/cache/lib/puppet/provider/rhsm_repo/subscription_manager.rb:50:in `block in prefetch'
/opt/puppetlabs/puppet/cache/lib/puppet/provider/rhsm_repo/subscription_manager.rb:48:in `each'
/opt/puppetlabs/puppet/cache/lib/puppet/provider/rhsm_repo/subscription_manager.rb:48:in `prefetch'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/transaction.rb:360:in `prefetch'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/transaction.rb:252:in `prefetch_if_necessary'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/transaction.rb:111:in `block in evaluate'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/graph/relationship_graph.rb:119:in `traverse'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/transaction.rb:173:in `evaluate'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/resource/catalog.rb:239:in `block (2 levels) in apply'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util.rb:519:in `block in thinmark'
/opt/puppetlabs/puppet/lib/ruby/2.4.0/benchmark.rb:308:in `realtime'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util.rb:518:in `thinmark'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/resource/catalog.rb:238:in `block in apply'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/log.rb:156:in `with_destination'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/transaction/report.rb:146:in `as_logging_destination'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/resource/catalog.rb:237:in `apply'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/configurer.rb:186:in `block (2 levels) in apply_catalog'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util.rb:519:in `block in thinmark'
/opt/puppetlabs/puppet/lib/ruby/2.4.0/benchmark.rb:308:in `realtime'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util.rb:518:in `thinmark'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/configurer.rb:185:in `block in apply_catalog'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util.rb:232:in `block in benchmark'
/opt/puppetlabs/puppet/lib/ruby/2.4.0/benchmark.rb:308:in `realtime'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util.rb:231:in `benchmark'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/configurer.rb:184:in `apply_catalog'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/configurer.rb:369:in `run_internal'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/configurer.rb:237:in `block in run'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/context.rb:65:in `override'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet.rb:260:in `override'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/configurer.rb:211:in `run'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/agent.rb:59:in `block (5 levels) in run'
/opt/puppetlabs/puppet/lib/ruby/2.4.0/timeout.rb:76:in `timeout'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/agent.rb:58:in `block (4 levels) in run'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/agent/locker.rb:21:in `lock'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/agent.rb:52:in `block (3 levels) in run'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/agent.rb:130:in `with_client'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/agent.rb:49:in `block (2 levels) in run'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/agent.rb:87:in `run_in_fork'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/agent.rb:48:in `block in run'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application.rb:179:in `controlled_run'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/agent.rb:46:in `run'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application/agent.rb:372:in `onetime'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application/agent.rb:350:in `run_command'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application.rb:375:in `block in run'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util.rb:667:in `exit_on_fail'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/application.rb:375:in `run'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/command_line.rb:135:in `run'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/util/command_line.rb:73:in `execute'
/opt/puppetlabs/puppet/bin/puppet:5:in `<main>'
waveclaw commented 5 years ago

This was changed to deal with the the RuboCop Lint/AssignmentInCondition failures that your PR is failing on. The majority of your Lint failures are due to either invalid Ruby combinations or more ridiculous tests from RuboCop. The two changes you propose were explicitly causing these errors and were removed in the prior version.

While the error has a terrible information, giving the lass Puppet 'programmer error message' undefined method `intern' for nil:NilClass, it is part of the current API for this type.

treydock commented 5 years ago

@waveclaw , if I fix rubocop can this get merged? Not sure I follow why this was closed other than rubocop issues. The pattern in this PR matches the other provider prefetching.

waveclaw commented 5 years ago

Yes.

Some customers will not accept a module with failing tests. Oddly enough, these customers are also happy if there are only useless or empty passing tests.

PDK writes .rubocop so there must be a continual fight to use any exceptions inserted. See the Constants warning for the facts for an example.

The PR you wrote reverts the Rubocop fixes I put in for 5.0 to please other customers.

If you want to bring the issue of the standard provider pattern violating Ruby community standards to the PDK developers you could get credit for this in two projects.

-- WaveClaw

-------- Original message -------- From: treydock notifications@github.com Date: 3/3/19 7:27 AM (GMT-07:00) To: waveclaw/puppet-subscription_manager puppet-subscription_manager@noreply.github.com Cc: JD Powell waveclaw@hotmail.com, Mention mention@noreply.github.com Subject: Re: [waveclaw/puppet-subscription_manager] Fix provider prefetching to handle resources not being present (#79)

@waveclawhttps://github.com/waveclaw , if I fix rubocop can this get merged? Not sure I follow why this was closed other than rubocop issues. The pattern in this PR matches the other provider prefetching.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/waveclaw/puppet-subscription_manager/pull/79#issuecomment-469028320, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AAEf6f_C0s2gbh8DoHqq6N4gPB94-P4zks5vS9vQgaJpZM4a6KsC.