waveclaw / puppet-subscription_manager

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

Could not update: undefined method `backtrace' for Puppet::Error:Class #27

Closed pgassmann closed 8 years ago

pgassmann commented 8 years ago
Info: Class[Subscription_manager::Defaults]: Starting to evaluate the resource
Info: Class[Subscription_manager::Defaults]: Evaluated in 0.00 seconds
Info: Class[Subscription_manager::Defaults]: Starting to evaluate the resource
Info: Class[Subscription_manager::Defaults]: Evaluated in 0.00 seconds
Info: Class[Subscription_manager::Install]: Starting to evaluate the resource
Info: Class[Subscription_manager::Install]: Evaluated in 0.00 seconds
Info: /Stage[main]/Subscription_manager::Install/Package[subscription-manager]: Starting to evaluate the resource
Info: /Stage[main]/Subscription_manager::Install/Package[subscription-manager]: Evaluated in 0.00 seconds
Debug: Prefetching rpm resources for package
Debug: Executing: '/usr/bin/rpm --version'
Debug: Executing '/usr/bin/rpm -qa --nosignature --nodigest --qf '%{NAME} %|EPOCH?{%{EPOCH}}:{0}| %{VERSION} %{RELEASE} %{ARCH}\n''
Info: /Stage[main]/Subscription_manager::Install/Package[katello-ca-consumer-mysatellite.example.com]: Starting to evaluate the resource
Debug: Executing: '/usr/bin/rpm -q katello-ca-consumer-mysatellite.example.com --nosignature --nodigest --qf %{NAME} %|EPOCH?{%{EPOCH}}:{0}| %{VERSION} %{RELEASE} %{ARCH}\n'
Debug: Executing: '/usr/bin/rpm -q katello-ca-consumer-mysatellite.example.com --nosignature --nodigest --qf %{NAME} %|EPOCH?{%{EPOCH}}:{0}| %{VERSION} %{RELEASE} %{ARCH}\n --whatprovides'
Debug: Executing: '/usr/bin/rpm -q --qf %{NAME} %|EPOCH?{%{EPOCH}}:{0}| %{VERSION} %{RELEASE} %{ARCH}\n -p http://mysatellite.example.com/pub/katello-ca-consumer-latest.noarch.rpm'
Error: Could not update: undefined method `backtrace' for Puppet::Error:Class
Error: /Stage[main]/Subscription_manager::Install/Package[katello-ca-consumer-mysatellite.example.com]/ensure: change from absent to latest failed: Could not update: undefined method `backtrace' for Puppet::Error:Class
Info: /Stage[main]/Subscription_manager::Install/Package[katello-ca-consumer-mysatellite.example.com]: Evaluated in 0.38 seconds
Info: Class[Subscription_manager::Install]: Starting to evaluate the resource
Debug: Class[Subscription_manager::Install]: Resource is being skipped, unscheduling all events
[root@eddie017 pa-puppetconfig]# /usr/bin/rpm -q katello-ca-consumer-mysatellite.example.com --nosignature --nodigest --qf "%{NAME} %|EPOCH?{%{EPOCH}}:{0}| %{VERSION} %{RELEASE} %{ARCH}\n" 
package katello-ca-consumer-mysatellite.example.com is not installed
[root@eddie017 pa-puppetconfig]# /usr/bin/rpm -q katello-ca-consumer-mysatellite.example.com --nosignature --nodigest --qf "%{NAME} %|EPOCH?{%{EPOCH}}:{0}| %{VERSION} %{RELEASE} %{ARCH}\n" --whatprovides
no package provides katello-ca-consumer-mysatellite.example.com
[root@eddie017 pa-puppetconfig]# /usr/bin/rpm -q --qf "%{NAME} %|EPOCH?{%{EPOCH}}:{0}| %{VERSION} %{RELEASE} %{ARCH}\n" -p http://mysatellite.example.com/pub/katello-ca-consumer-latest.noarch.rpm
curl: (6) Could not resolve host: mysatellite.example.com; Name or service not known
error: open of http://mysatellite.example.com/pub/katello-ca-consumer-latest.noarch.rpm failed: No such file or directory

The file that is checked in the fact does not exist

[root@eddie017 pa-puppetconfig]# ls /etc/rhsm/ca/ -lah
total 8.0K
drwxr-xr-x. 2 root root   27 Jul 12 11:32 .
drwxr-xr-x. 5 root root   81 Jul 12 11:33 ..
-rw-r--r--. 1 root root 7.6K Sep 11  2015 redhat-uep.pem
pgassmann commented 8 years ago

Seems to be related to #23 as it also uses the File.exists confine and even though the file does not exist, the fact is executed.

But the backtrace method error is something else to fix.

waveclaw commented 8 years ago

This is a trace of the application of subscription_manager. It appears to be trying to install the katello consumer CA package needed to replace the redhat-uep.pem file in /etc/rhsm/ca.

That redhat-uep file is provided by the python-rhsm package which is part of the subscription-manager plugin from RedHat.

[root@katello ~]# rpm -q --whatprovides /etc/rhsm/ca/redhat-uep.pem
python-rhsm-1.15.4-5.el7.x86_64

The error you list is from the package provider for your system trying to install Satellite or Katello's replacement package for this certificate. The path is very simple to follow:

  1. the error was generated by the Package type trying to ensure a package
  2. the package resource's title was katello-ca-consumer-mysatellite.example.com
  3. the resource was requested in the install sub-class
  4. the sub-class is inside the subscription_manager class
  5. which is a class included in the main of Stage of the catalog apply for a node.

Error: /Stage[main]/Subscription_manager::Install/Package[katello-ca-consumer-mysatellite.example.com]/ensure: change from absent to latest failed: Could not update: undefined methodbacktrace' for Puppet::Error:Class``

If this is a problem with the package provider in your Puppet environment I cannot help you by changing code in subscription_manager.

The only place in subscription_manager that calls backtrace is the duplicated begin..end statements in the facts that were donated. (Those still need a refactor but I hate making Ruby code obtuse just to reduce repeating code. There's already far too much meta-for-the-sake-of-meta in Puppet's code base.)

The subscription_manager module uses strict ordered dependencies between the top-level classes. This error appears inside the install class. Since Puppet later versions have working containment this should not be causing any resource or class to float off the graph. But that does not completely preclude a random class sneaking into the order after the package ensure failure. But this install class uses Puppet transition which alters the catalog non-trivially.

Still, just in case this might be caused by something floating about the catalog, what does the dependency graph for a minimal catalog with this issue look like?

Now in the use case where

  1. the registration is bad
  2. but the hostname is unchanged
  3. and force is provided a transition is used in the catalog. This transition temporarily removes the CA package before trying to reinstall it. This is so the correct current CA package gets installed. That can create very strange catalogs and resource orderings.

In this example, are you trying to re-subscribe a system with a registration?

pgassmann commented 8 years ago

I created an upstream Ticket for the Bug: https://tickets.puppetlabs.com/browse/PUP-6517

waveclaw commented 8 years ago

Ouch, DNS resolver bug?

There's a couple weird errors Puppet will generate if DNS is not working as expected. Puppet 4 dies in collecting facter facts with an error on 'Cannot resolve master' if the local system's hostname is not resovable from /etc/hosts, DNS or something else like NIS+.

I hope your issue gets visibility.