chef-boneyard / redhat-subscription-manager-cookbook

Cookbook providing custom resources for interacting with Red Hat Subscription Manager
Apache License 2.0
4 stars 18 forks source link

System registration sometimes fails #28

Open jayhendren opened 7 years ago

jayhendren commented 7 years ago

Strictly speaking, this is not an issue with this cookbook, but rather with RHSM. In any case, I believe it will be easier to work around this issue by providing some leniency within this cookbook rather than convincing Red Hat to make RHSM more reliable.

Every now and then, on system registration, we see the following error:

             ================================================================================
             Error executing action `run` on resource 'execute[Register to RHSM]'
             ================================================================================

             Mixlib::ShellOut::ShellCommandFailed
             ------------------------------------
             Expected process to exit with [0], but received '70'
             ---- Begin output of subscription-manager register --activationkey=****** --org=****** ----
             STDOUT: The system has been registered with ID: 35d8c7ce-7e4a-481d-af97-04b1720c3ab2
             STDERR: Network error, unable to connect to server. Please see /var/log/rhsm/rhsm.log for more information.
             ---- End output of subscription-manager register --activationkey=****** --org=****** ----
             Ran subscription-manager register --activationkey=****** --org=****** returned 70

             Cookbook Trace:
             ---------------
             /tmp/kitchen/cache/cookbooks/cub_redhat_subscription_manager/recipes/default.rb:53:in `from_file'
             /tmp/kitchen/cache/cookbooks/cub_policy_common/recipes/default.rb:8:in `from_file'
             /tmp/kitchen/cache/cookbooks/cub_fis_db_common/recipes/default.rb:1:in `from_file'
             /tmp/kitchen/cache/cookbooks/cub_policy_fis_db_prod/recipes/default.rb:6:in `from_file'

             Resource Declaration:
             ---------------------
             # In /tmp/kitchen/cache/cookbooks/redhat_subscription_manager/libraries/rhsm_register.rb

       55:       execute 'Register to RHSM' do # ~FC009
       56:         sensitive new_resource.sensitive
       57:         command register_command
       58:         action :run
       59:         not_if { registered_with_rhsm? }
       60:       end
       61: 

             Compiled Resource:
             ------------------
             # Declared in /tmp/kitchen/cache/cookbooks/redhat_subscription_manager/libraries/rhsm_register.rb:55:in `block in <class:RhsmRegister>'

             execute("Register to RHSM") do
        action [:run]
        retries 0
        retry_delay 2
        default_guard_interpreter :execute
        command "subscription-manager register --activationkey=****** --org=******"
        backup 5
        returns 0
        declared_type :execute
        cookbook_name "cub_redhat_subscription_manager"
        not_if { #code block }
             end

             Platform:
             ---------
             x86_64-linux

The vast majority of the time, re-running registration fixes the issue.

This can be somewhat irritating since the failed registration interrupts otherwise automated processes (bootstrapping a new system or running functional tests via our CI/CD server) and requires manual intervention. I believe adding the ability to retry registration a few times would adequately address this issue.

jayhendren commented 7 years ago

Ah, it appears even custom resources support retries and retry_delay. This may be what I want.