Bug 2232316 - [Regression] "force=true" is ignored in D-Bus "Register" and "RegisterWithActivationKeys" methods
Summary: [Regression] "force=true" is ignored in D-Bus "Register" and "RegisterWithAct...
Keywords:
Status: POST
Alias: None
Product: Red Hat Enterprise Linux 9
Classification: Red Hat
Component: subscription-manager
Version: 9.3
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: rc
: 9.3
Assignee: Pino Toscano
QA Contact: CSI Client Tools Bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2023-08-16 09:44 UTC by Pino Toscano
Modified: 2023-08-17 16:36 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: No Doc Update
Doc Text:
Clone Of:
Environment:
Last Closed:
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github candlepin subscription-manager pull 3311 0 None open 2232316: fix D-Bus regressions 2023-08-16 10:11:34 UTC
Red Hat Issue Tracker RHELPLAN-165893 0 None None None 2023-08-16 10:13:41 UTC

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


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