Bug 1341712

Summary: Error registering a host after the upgrade has completed
Product: Red Hat Satellite Reporter: Brad Buckingham <bbuckingham>
Component: UpgradesAssignee: Brad Buckingham <bbuckingham>
Status: CLOSED ERRATA QA Contact: Sachin Ghai <sghai>
Severity: high Docs Contact:
Priority: unspecified    
Version: 6.2.0CC: cwelton, sghai
Target Milestone: UnspecifiedKeywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: rubygem-katello-3.0.0.43-1 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-07-27 11:13:58 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1335807    
Attachments:
Description Flags
production.log during failed sub-man register none

Description Brad Buckingham 2016-06-01 14:51:34 UTC
Created attachment 1163707 [details]
production.log during failed sub-man register

Description of problem:

If prior to a Satellite 6.2 upgrade, there is a host registered where the Host and Content Host are in different organizations (e.g. host not in org, and content host in one), the content host will be unregistered as part of the upgrade process.  When this occurs, after the upgrade is completed, the user would need to re-register the host with the Satellite for content and subscription capabilities.  Unfortunately, this is currently causing an error.

Note: this does not affect all registrations after upgrade, only those that met the scenario above.

Version-Release number of selected component (if applicable):
Satellite 6.2 Snap 13.1

How reproducible:
Always

Steps to Reproduce:
1. install Satellite 6.1
2. install Capsule 6.1
3. subscription-manager register the Capsule to the Satellite
4. ensure that the Host associated with the Capsule is not in an organization and the Content Host is
5. perform an upgrade of the Satellite 6.1 to 6.2
6. after the upgrade completes, attempt to register the Capsule back to the Satellite

Actual results:

[root@capsule61-rhel7 ~]# subscription-manager register --org="Default_Organization" --activationkey="key"
Task 5b28c9ed-f36d-44f5-aa85-5363363efc72: RestClient::ResourceNotFound: 404 Resource Not Found

Snippet from the logs:
2016-06-01 03:00:55 [app] [I] Started POST "/rhsm/consumers?owner=Default_Organization&activation_keys=key" for 192.168.121.198 at 2016-06-01 03:00:55 +0000
2016-06-01 03:00:55 [app] [I] Processing by Katello::Api::Rhsm::CandlepinProxiesController#consumer_activate as JSON
2016-06-01 03:00:55 [app] [I]   Parameters: {"facts"=>"[FILTERED]", "installedProducts"=>[{"productName"=>"Red Hat Enterprise Linux Server", "arch"=>"x86_64", "version"=>"7.2", "productId"=>"69"}, {"productName"=>"Red Hat Satellite Capsule", "arch"=>"x86_64", "version"=>"6.1", "productId"=>"269"}], "type"=>"system", "name"=>"capsule61-rhel7.example.com", "contentTags"=>["satellite-capsule", "satellite-capsule-6.1", "rhel-7", "rhel-7-server"], "owner"=>"Default_Organization", "activation_keys"=>"key"}
2016-06-01 03:01:04 [katello/pulp_rest] [I] RestClient.delete "https://sat61-rhel7.example.com/pulp/api/v2/consumers/ded17adf-5e57-4865-ac7c-773bd99d4e4d/", "Accept"=>"*/*; q=0.5, application/xml", "Accept-Encoding"=>"gzip, deflate", "accept"=>"application/json", "content_type"=>"application/json"
 | \n# => 404 NotFound | application/json 528 bytes
 | 
...
...

Expected results:

Registration completes successfully

Additional info:

Comment 1 Brad Buckingham 2016-06-01 14:54:03 UTC
Note: If an error occurs during the registration, the user can work around it by performing the following:

1. log in to the UI
2. go to Monitor -> Tasks
3. locate the failed registration task
4. go to the Dynflow console for that task
5. 'skip' the deletion of the pulp consumer and 'resume' the task
6. re-register the host using 'subscription-manager'

Comment 2 Brad Buckingham 2016-06-01 15:25:47 UTC
Created redmine issue http://projects.theforeman.org/issues/15260 from this bug

Comment 4 Sachin Ghai 2016-06-03 09:02:44 UTC
Reproduced with upgrade from sat6.1.9 -> sat6.2 GA snap14.1

~]# subscription-manager register --org Default_Organization --activationkey 'ak_rhel7'
Task bd3dc14e-3c7d-4c3d-af67-0439675140a9: RestClient::ResourceNotFound: 404 Resource Not Found


[I] Started POST "/rhsm/consumers?owner=Default_Organization&activation_keys=ak_rhel7" for 10.8.193.1 at 2016-06-03 04:51:27 -0400
2016-06-03 04:51:27 [app] [I] Processing by Katello::Api::Rhsm::CandlepinProxiesController#consumer_activate as JSON
2016-06-03 04:51:27 [app] [I]   Parameters: {"facts"=>"[FILTERED]", "installedProducts"=>[{"productName"=>"Red Hat Enterprise Linux Server", "arch"=>"x86_64", "version"=>"7.2", "productId"=>"69"}, {"productName"=>"Red Hat Satellite Capsule", "arch"=>"x86_64", "version"=>"6.1", "productId"=>"269"}], "type"=>"system", "name"=>"qe-capsule-rhel7.satqe.lab.eng.rdu2.redhat.com", "contentTags"=>["satellite-capsule", "satellite-capsule-6.1", "rhel-7", "rhel-7-server"], "owner"=>"Default_Organization", "activation_keys"=>"ak_rhel7"}
2016-06-03 04:51:33 [katello/pulp_rest] [I] RestClient.delete "https://qe-sat6-upgrade-rhel7.satqe.lab.eng.rdu2.redhat.com/pulp/api/v2/consumers/c1d5c956-b9c5-4088-914b-fd5e0e828c32/", "Accept"=>"*/*; q=0.5, application/xml", "Accept-Encoding"=>"gzip, deflate", "accept"=>"application/json", "content_type"=>"application/json"
 | \n# => 404 NotFound | application/json 528 bytes
 | 
2016-06-03 04:51:33 [foreman-tasks/action] [E] 404 Resource Not Found (RestClient::ResourceNotFound)

Comment 5 Sachin Ghai 2016-06-03 09:12:37 UTC
Note: given workaround works

Comment 6 Sachin Ghai 2016-06-10 08:08:55 UTC
Verified with upgrade from sat6.1.9 -> sat6.2 GA snap15.1 on rhel7. The
reported issue is fixed now. 

After successful upgrade of satellite, capsule got unregistered as host with same name was not in org but content-host with same name was in an org. So as per host unification, content-host got unregistered. So I re-registered the capsule:

~]# yum repolist
Loaded plugins: package_upload, product-id, search-disabled-repos, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
repolist: 0
[root@qe-capsule-rhel7 ~]# subscription-manager register --org Default_Organization --activationkey 'ak-rhel7'
Couldn't find activation key 'ak-rhel7'
[root@qe-capsule-rhel7 ~]# subscription-manager register --org Default_Organization --activationkey 'ak_rhel7'The system has been registered with ID: 6d7d9d1a-87de-4f80-ac41-06481e412aba 

Installed Product Current Status:
Product Name: Red Hat Enterprise Linux Server
Status:       Subscribed

Product Name: Red Hat Satellite Capsule
Status:       Subscribed

Comment 7 Bryan Kearney 2016-07-27 11:13:58 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2016:1501