Bug 2232316

Summary: [Regression] "force=true" is ignored in D-Bus "Register" and "RegisterWithActivationKeys" methods
Product: Red Hat Enterprise Linux 9 Reporter: Pino Toscano <ptoscano>
Component: subscription-managerAssignee: Pino Toscano <ptoscano>
Status: CLOSED ERRATA QA Contact: CSI Client Tools Bugs <csi-client-tools-bugs>
Severity: high Docs Contact:
Priority: high    
Version: 9.3CC: cdonnell, jharuda, jsefler, jstavel, rmeggins
Target Milestone: rcKeywords: Regression, Triaged
Target Release: 9.3   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: subscription-manager-1.29.37-1.el9 Doc Type: No Doc Update
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-11-07 08:51:54 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:

Description Pino Toscano 2023-08-16 09:44:34 UTC
Description of problem:
Due to a small logic issue in a recent D-Bus refactor [1], the "force=true" registration option in the "Register" and "RegisterWithActivationKeys" registration methods is no longer taken into account. This means that trying to register using "force=true" on an already registered system will fail with "This system is already registered." rather than unregistering and registering as requested.

This can be reproduced e.g. by using the "rhc" Ansible system role:

    - name: Register
      include_role:
        name: linux-system-roles.rhc
      vars:
        rhc_auth:
          login:
            username: "working-username"
            password: "working-password"
        rhc_insights:
          state: absent
        rhc_state: present

    - name: Register (forced)
      include_role:
        name: linux-system-roles.rhc
      vars:
        rhc_auth:
          login:
            username: "working-username"
            password: "working-password"
        rhc_insights:
          state: absent
        rhc_state: reconnect

(tweaking the role parameters as needed; this is extracted from one of the tests of the role, tests_register_unregister.yml [2])

Credit goes to the system roles team (Jakub Haruda & Richard Megginson) for discovering this issue in latest 9.3 composes.

[1] https://github.com/candlepin/subscription-manager/pull/3283
[2] https://github.com/linux-system-roles/rhc/blob/71b9dbb08d7b1899071253f336642212ac4d34d7/tests/tests_register_unregister.yml

Version-Release number of selected component (if applicable):
subscription-manager-1.29.36-1.el9
(earlier versions are not affected)

Comment 1 Jan Stavel 2023-08-17 16:36:41 UTC
I have verified a fix.
result of run of the playbook: 
   a version without the fix:

.... reregistering of a system
TASK [fedora.linux_system_roles.rhc : Call subscription-manager] **************************************************************************************************************************************************
fatal: [ibm-x3650m4-01-vm-13.ibm2.lab.eng.bos.redhat.com]: FAILED! => changed=false 
  msg: 'Failed to register with ''subscription.rhsm.stage.redhat.com'': com.redhat.RHSM1.Error: {"exception": "DBusException", "severity": "error", "message": "This system is already registered."}'

TASK [Get rhsm UUID] **********************************************************************************************************************************************************************************************
included: /home/jstavel/Projects/rhsm-ansible-qe/playbooks/tasks/get_rhsm_uuid.yml for ibm-x3650m4-01-vm-13.ibm2.lab.eng.bos.redhat.com

TASK [Run subscription-manager identity] **************************************************************************************************************************************************************************
ok: [ibm-x3650m4-01-vm-13.ibm2.lab.eng.bos.redhat.com]

TASK [Rename the rhsm UUID to test_rhsm_uuid_after] ***************************************************************************************************************************************************************
ok: [ibm-x3650m4-01-vm-13.ibm2.lab.eng.bos.redhat.com]

TASK [Version of subscription-manager] ****************************************************************************************************************************************************************************
changed: [ibm-x3650m4-01-vm-13.ibm2.lab.eng.bos.redhat.com]

TASK [Version of subscription-manager] ****************************************************************************************************************************************************************************
ok: [ibm-x3650m4-01-vm-13.ibm2.lab.eng.bos.redhat.com] => 
  msg: |-
    Version of subscription-manager is subscription-manager-rhsm-certificates-20220623-1.el9.noarch
    subscription-manager-cockpit-6^44.g48f19d5-1.el9.noarch
    python3-subscription-manager-rhsm-1.29.36-1.el9.x86_64
    libdnf-plugin-subscription-manager-1.29.36-1.el9.x86_64
    subscription-manager-1.29.36-1.el9.x86_64

TASK [UUID before and after] **************************************************************************************************************************************************************************************
ok: [ibm-x3650m4-01-vm-13.ibm2.lab.eng.bos.redhat.com] => 
  msg: |-
    UUID before reregistering is be195943-704f-4926-809a-71ccc441e150
    UUID after  reregistering is be195943-704f-4926-809a-71ccc441e150

TASK [Check the rhsm UUID changed] ********************************************************************************************************************************************************************************
fatal: [ibm-x3650m4-01-vm-13.ibm2.lab.eng.bos.redhat.com]: FAILED! => changed=false 
  assertion: test_rhsm_uuid_before.stdout != test_rhsm_uuid_after.stdout
  evaluated_to: false
  msg: consumer UUID before reregistration must be different from the one after reregistration

PLAY RECAP ********************************************************************************************************************************************************************************************************
ibm-x3650m4-01-vm-13.ibm2.lab.eng.bos.redhat.com : ok=24   changed=1    unreachable=0    failed=2    skipped=10   rescued=0    ignored=0   




a run with the fix:

TASK [fedora.linux_system_roles.rhc : Call subscription-manager] **************************************************************************************************************************************************
changed: [ibm-x3650m4-01-vm-13.ibm2.lab.eng.bos.redhat.com]

TASK [fedora.linux_system_roles.rhc : Set or unset the release] ***************************************************************************************************************************************************
skipping: [ibm-x3650m4-01-vm-13.ibm2.lab.eng.bos.redhat.com]

TASK [fedora.linux_system_roles.rhc : Configure repositories] *****************************************************************************************************************************************************
skipping: [ibm-x3650m4-01-vm-13.ibm2.lab.eng.bos.redhat.com]

TASK [fedora.linux_system_roles.rhc : Handle insights registration] ***********************************************************************************************************************************************
skipping: [ibm-x3650m4-01-vm-13.ibm2.lab.eng.bos.redhat.com]

TASK [Get rhsm UUID] **********************************************************************************************************************************************************************************************
included: /home/jstavel/Projects/rhsm-ansible-qe/playbooks/tasks/get_rhsm_uuid.yml for ibm-x3650m4-01-vm-13.ibm2.lab.eng.bos.redhat.com

TASK [Run subscription-manager identity] **************************************************************************************************************************************************************************
ok: [ibm-x3650m4-01-vm-13.ibm2.lab.eng.bos.redhat.com]

TASK [Rename the rhsm UUID to test_rhsm_uuid_after] ***************************************************************************************************************************************************************
ok: [ibm-x3650m4-01-vm-13.ibm2.lab.eng.bos.redhat.com]

TASK [Version of subscription-manager] ****************************************************************************************************************************************************************************
changed: [ibm-x3650m4-01-vm-13.ibm2.lab.eng.bos.redhat.com]

TASK [Version of subscription-manager] ****************************************************************************************************************************************************************************
ok: [ibm-x3650m4-01-vm-13.ibm2.lab.eng.bos.redhat.com] => 
  msg: |-
    Version of subscription-manager is subscription-manager-rhsm-certificates-20220623-1.el9.noarch
    subscription-manager-cockpit-6^44.g48f19d5-1.el9.noarch
    python3-subscription-manager-rhsm-1.29.36+11.gd7d787f2f-1.git.0.12898dd.x86_64
    libdnf-plugin-subscription-manager-1.29.36+11.gd7d787f2f-1.git.0.12898dd.x86_64
    subscription-manager-1.29.36+11.gd7d787f2f-1.git.0.12898dd.x86_64

TASK [UUID before and after] **************************************************************************************************************************************************************************************
ok: [ibm-x3650m4-01-vm-13.ibm2.lab.eng.bos.redhat.com] => 
  msg: |-
    UUID before reregistering is be195943-704f-4926-809a-71ccc441e150
    UUID after  reregistering is b1482658-597d-4245-8849-53012a7e3aff

TASK [Check the rhsm UUID changed] ********************************************************************************************************************************************************************************
ok: [ibm-x3650m4-01-vm-13.ibm2.lab.eng.bos.redhat.com] => changed=false 
  msg: consumer UUID before reregistration must be different from the one after reregistration

PLAY RECAP ********************************************************************************************************************************************************************************************************
ibm-x3650m4-01-vm-13.ibm2.lab.eng.bos.redhat.com : ok=26   changed=2    unreachable=0    failed=0    skipped=13   rescued=0    ignored=0

Comment 8 errata-xmlrpc 2023-11-07 08:51:54 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 (subscription-manager bug fix and enhancement update), 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-2023:6606