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

Rhsm_register should fail when underlying command fails #87

Open
jameslikeslinux opened this issue Sep 27, 2019 · 1 comment
Open

Rhsm_register should fail when underlying command fails #87

jameslikeslinux opened this issue Sep 27, 2019 · 1 comment

Comments

@jameslikeslinux
Copy link

jameslikeslinux commented Sep 27, 2019

My organization has been using this module for several years. Thank you for it.

We have observed that when host registration fails, the rhsm_register resource returns successfully. This can cause problems for other resources that depend on our rhsm_register resource, and it is confusing trying to identify where the problem is when reading Puppet reports.

For example, if we provide a fake activation key, on the command line we get:

> subscription-manager register --org="dit" --activationkey="fake"
HTTP error (404 - Not Found): Couldn't find activation key 'fake'
> echo $?
70

And providing the same fake activation key to the rhsm_resource, we get:

Notice: /Stage[first]/Satellite_client::Config/Rhsm_register[satellite-server-name]/ensure: created (corrective)

When turning on the --debug option, we see the detailed error message, but the resource is still considered to have returned successfully:

Notice: /Stage[first]/Satellite_client::Config/Rhsm_register[satellite-server-name]/ensure: created (corrective)
Debug: This server will be registered
Debug: Executing: '/usr/sbin/subscription-manager register --activationkey foo --org dit'
Debug: Registration returned: Execution of '/usr/sbin/subscription-manager register --activationkey foo --org dit' returned 70: HTTP error (404 - Not Found): Couldn't find activation key 'foo'

I believe this is because the subscription-manager command failure is caught and not re-raised at https://github.com/waveclaw/puppet-subscription_manager/blob/master/lib/puppet/provider/rhsm_register/subscription_manager.rb#L55. Is there a reason for this? I'm happy to submit a patch if this is something that should be corrected.

Thanks.

@waveclaw
Copy link
Owner

waveclaw commented Oct 9, 2019

The command returns unusual return values so a blanket catch was used.

On some of the older branches there are some attempts to process these return codes but they never resulted in workable solutions in the field.

If you have a working implemtnation of handling the return data from subscription-manager, please do submit a patch. I would be very interested in testing it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants