Red Hat Satellite engineering is moving the tracking of its product development work on Satellite to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "Satellite project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs will be migrated starting at the end of May. If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "Satellite project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/SAT-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1717006 - `subscription-manager register --force ...` complains "HTTP error (422 - Unknown): Please unregister or remove hosts which match this host before registering: ..."
Summary: `subscription-manager register --force ...` complains "HTTP error (422 - Unkn...
Keywords:
Status: CLOSED DUPLICATE of bug 1730146
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Registration
Version: 6.6.0
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: Unspecified
Assignee: satellite6-bugs
QA Contact: Stephen Wadeley
URL:
Whiteboard:
: 1730883 (view as bug list)
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2019-06-04 14:17 UTC by Jan Hutař
Modified: 2019-07-22 21:05 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-07-22 21:05:58 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
Relevant part of production.log (13.63 KB, text/plain)
2019-06-04 14:28 UTC, Jan Hutař
no flags Details

Description Jan Hutař 2019-06-04 14:17:04 UTC
Description of problem:
`subscription-manager register --force ...` complains "HTTP error (422 - Unknown): Please unregister or remove hosts which match this host before registering: ..." (i.e. even with that "--force" option)


Version-Release number of selected component (if applicable):
Server: Satellite 6.6 snap #5
Client:
  subscription-manager-1.21.10-3.el7_6.x86_64
  subscription-manager-plugin-container-1.21.10-3.el7_6.x86_64
  subscription-manager-rhsm-1.21.10-3.el7_6.x86_64
  subscription-manager-rhsm-certificates-1.21.10-3.el7_6.x86_64


How reproducible:
always


Steps to Reproduce:
1. On a Satellite create the host:
   # hammer -v -u admin -p ... --output=csv host subscription register --organization-id="..." --content-view-id="..." --lifecycle-environment-id="..." --name="..."
2. 
2. On a client attempt to register:
   # rpm -Uvh http://qe-sat66-rhel7-tier3.satqe.lab.eng.rdu2.redhat.com/pub/katello-ca-consumer-latest.noarch.rpm
3. Register:
   # tail -n 0 -f /var/log/rhsm/rhsm.log &
   # subscription-manager register --org ... --activationkey ... --force
   (same happens with username & password)


Actual results:
[root@jkoqdhol1ku6zx7x ~]# subscription-manager register --org AiLUyy --activationkey vU2n6CHmSh --force
2019-06-04 10:10:24,814 [INFO] subscription-manager:4119:MainThread @managercli.py:457 - X-Correlation-ID: e3dc9043f04345508ee564ec8e7b62f5
2019-06-04 10:10:24,815 [INFO] subscription-manager:4119:MainThread @managercli.py:346 - Client Versions: {'subscription-manager': '1.21.10-3.el7_6'}
2019-06-04 10:10:24,815 [INFO] subscription-manager:4119:MainThread @connection.py:871 - Connection built: host=satellite.nodhcp.local port=443 handler=/rhsm auth=identity_cert ca_dir=/etc/rhsm/ca/ insecure=False
2019-06-04 10:10:24,815 [INFO] subscription-manager:4119:MainThread @connection.py:871 - Connection built: host=satellite.nodhcp.local port=443 handler=/rhsm auth=none
2019-06-04 10:10:24,816 [INFO] subscription-manager:4119:MainThread @managercli.py:346 - Client Versions: {'subscription-manager': '1.21.10-3.el7_6'}
2019-06-04 10:10:24,829 [INFO] subscription-manager:4119:MainThread @managercli.py:322 - Consumer Identity name=None uuid=None
2019-06-04 10:10:24,830 [INFO] subscription-manager:4119:MainThread @managercli.py:322 - Consumer Identity name=None uuid=None
2019-06-04 10:10:24,830 [INFO] subscription-manager:4119:MainThread @connection.py:871 - Connection built: host=satellite.nodhcp.local port=443 handler=/rhsm auth=none
2019-06-04 10:10:24,866 [INFO] subscription-manager:4119:MainThread @dmiinfo.py:75 - Using dmidecode dump file: /dev/mem
HTTP error (422 - Unknown): Please unregister or remove hosts which match this host before registering: jkoqdhol1ku6zx7x.nodhcp.local
2019-06-04 10:10:25,165 [INFO] subscription-manager:4119:MainThread @connection.py:588 - Response: status=422, request="POST /rhsm/consumers?owner=AiLUyy&activation_keys=vU2n6CHmSh"
2019-06-04 10:10:25,166 [WARNING] subscription-manager:4119:MainThread @connection.py:592 - Clock skew detected, please check your system time
2019-06-04 10:10:25,166 [ERROR] subscription-manager:4119:MainThread @managercli.py:1122 - HTTP error (422 - Unknown): Please unregister or remove hosts which match this host before registering: jkoqdhol1ku6zx7x.nodhcp.local
Traceback (most recent call last):
  File "/usr/lib64/python2.7/site-packages/subscription_manager/managercli.py", line 1119, in _do_command
    type=self.options.consumertype
  File "/usr/lib64/python2.7/site-packages/rhsmlib/services/register.py", line 80, in register
    type=type
  File "/usr/lib64/python2.7/site-packages/rhsm/connection.py", line 969, in registerConsumer
    return self.conn.request_post(url, params)
  File "/usr/lib64/python2.7/site-packages/rhsm/connection.py", line 696, in request_post
    return self._request("POST", method, params, headers=headers)
  File "/usr/lib64/python2.7/site-packages/rhsm/connection.py", line 719, in _request
    info=info, headers=headers)
  File "/usr/lib64/python2.7/site-packages/rhsm/connection.py", line 597, in _request
    self.validateResponse(result, request_type, handler)
  File "/usr/lib64/python2.7/site-packages/rhsm/connection.py", line 656, in validateResponse
    raise RestlibException(response['status'], error_msg, response.get('headers'))
RestlibException: HTTP error (422 - Unknown): Please unregister or remove hosts which match this host before registering: jkoqdhol1ku6zx7x.nodhcp.local


Expected results:
It should work

Comment 3 Jan Hutař 2019-06-04 14:19:36 UTC
Moving to Satellite, because when I remove the host on Satellite UI, then register it (with same command) and attempt to register it again (so it exists in Satellite), it works. Looks like Satellite is somehow blocking host deletion when it was created with hammer?

Comment 7 Jan Hutař 2019-06-04 14:28:24 UTC
Created attachment 1577148 [details]
Relevant part of production.log

Comment 10 Rich Jerrido 2019-06-04 17:27:40 UTC
I think a discussion should be had as to what the expected behavior should be here? 


Two options

[1] Passing --force shouldn't delete a host entry

[2] Passing --force should delete or reuse a host entry. 


The behavior (as I understand), used to be [2], and now we made an explicit change (see comments #8 & #9) to change it to [1]. So this isn't a regression. However, we can deliver the error message more cleanly than a traceback.

Comment 12 Jonathon Turel 2019-06-09 19:56:18 UTC
Hey Jan & Rich,

The '--force' flag in subscription-manager is interesting in that it doesn't actually send force=true/false to the satellite server. Only subscription-manager itself cares about --force and it's used to check whether the client already has a valid identity cert *locally* which indicates it was not unregistered properly and/or fully before another register attempt was made. Just wanted to clarify on what the flag actually does.

Rich, you're right that we've moved from [2] to [1] but it doesn't necessarily hinge on --force based on the above explanation. As far as the stack trace - that's from the rhsm.log so I think it's OK and only the error message itself is shown when using subman.

I don't think this is a bug, but let me know if I missed anything or can clarify more. Thanks

Comment 13 Jan Hutař 2019-06-10 07:28:34 UTC
In docs, it says simply:

# subscription-manager register --help | grep force
  --force               register the system even if it is already registered
# rpm -q subscription-manager
subscription-manager-1.21.10-3.el7_6.x86_64

Comment 14 Jonathon Turel 2019-06-10 13:08:40 UTC
Jan, I agree that the documentation for the flag is a little ambiguous & could be improved. Something like 'attempt to register the system even if it already has a local identity certificate'

Comment 15 Stephen Wadeley 2019-07-18 10:15:42 UTC
Hello

Re comment 14

Bug 1731109 - Fix man page & help for --force option

Comment 16 Brad Buckingham 2019-07-22 21:03:16 UTC
*** Bug 1730883 has been marked as a duplicate of this bug. ***

Comment 17 Brad Buckingham 2019-07-22 21:05:58 UTC
This bugzilla was opened first; however, there is another bugzilla was raised and has had some additional investigation associated with it.  Since that bug has an updated redmine, I am going to close this one as a duplicate.  If there are any concerns, please feel free to reopen with appropriate details.

*** This bug has been marked as a duplicate of bug 1730146 ***


Note You need to log in before you can comment on or make changes to this bug.