RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 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 "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". 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 "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-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 1653387 - syspurpose file contents are restored after the cert check post the file is manually deleted
Summary: syspurpose file contents are restored after the cert check post the file is m...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: subscription-manager
Version: 8.0
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: 8.0
Assignee: candlepin-bugs
QA Contact: Red Hat subscription-manager QE Team
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2018-11-26 17:13 UTC by Rehana
Modified: 2020-12-15 09:26 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-12-15 09:05:22 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Rehana 2018-11-26 17:13:17 UTC
Description of problem:
syspurpose file contents are restored after the cert check post the file is manually deleted 

Version-Release number of selected component (if applicable):
subscription management server: 2.3.10-1
subscription management rules: 5.29
subscription-manager: 1.23.8-1.el8

How reproducible:
Not always 

Steps to Reproduce:
1.set some values for systempurpose attributes 
ex: 
# syspurpose show
{
  "addons": [
    "Resilient storage",
    "foo"
  ],
  "service_level_agreement": "",
  "usage": "Product",
  "role": "RHEL Server"
}
2.set certcheck to a shorter duration say for ex: 3mins
3.manually remove syspurpose.json file ,ex :  rm -rf /etc/rhsm/syspurpose/syspurpose.json
Ex:
[root@cav-sabre-cn99xx-01 ~]# rm -rf /etc/rhsm/syspurpose/syspurpose.json
[root@cav-sabre-cn99xx-01 ~]# syspurpose show
{}

4. Wait for the cert check to finish and execute syspurpose show 

Actual results:
Notice that the value set at step 1 was restored

Expected results:
It is expected the file to unset all the system purpose attributes once the file is remove manually and no restoration of the file is expected.

Additional info:

Comment 1 Craig Donnelly 2018-11-27 17:45:14 UTC
This also breaks for making changes directly to the file:

[root@unused ~]# vi /etc/rhsm/syspurpose/syspurpose.json 
[root@unused ~]# syspurpose show
{
  "usage": "QA",
  "addons": [],
  "role": "RHEL Workstation",
  "service_level_agreement": "Premium"
}
[root@unused ~]# systemctl restart rhsmcertd
[root@unused ~]# systemctl status rhsmcertd
● rhsmcertd.service - Enable periodic update of entitlement certificates.
   Loaded: loaded (/usr/lib/systemd/system/rhsmcertd.service; enabled; vendor preset: enabled)
   Active: active (running) since Tue 2018-11-27 12:36:51 EST; 5s ago
  Process: 9380 ExecStart=/usr/bin/rhsmcertd (code=exited, status=0/SUCCESS)
 Main PID: 9381 (rhsmcertd)
    Tasks: 1 (limit: 25030)
   Memory: 284.0K
   CGroup: /system.slice/rhsmcertd.service
           └─9381 /usr/bin/rhsmcertd

Nov 27 12:36:51 unused systemd[1]: Stopped Enable periodic update of entitlement certificates..
Nov 27 12:36:51 unused systemd[1]: Starting Enable periodic update of entitlement certificates....
Nov 27 12:36:51 unused systemd[1]: Started Enable periodic update of entitlement certificates..
[root@unused ~]# tail -f /var/log/rhsm/rhsmcertd.log 
Tue Nov 27 03:38:55 2018 [INFO] (Cert Check) Certificates updated.
Tue Nov 27 07:38:56 2018 [INFO] (Cert Check) Certificates updated.
Tue Nov 27 10:25:55 2018 [INFO] (Auto-attach) Certificates updated.
Tue Nov 27 11:38:56 2018 [INFO] (Cert Check) Certificates updated.
Tue Nov 27 12:36:51 2018 [INFO] rhsmcertd is shutting down...
Tue Nov 27 12:36:51 2018 [INFO] Starting rhsmcertd...
Tue Nov 27 12:36:51 2018 [INFO] Auto-attach interval: 1440.0 minutes [86400 seconds]
Tue Nov 27 12:36:51 2018 [INFO] Cert check interval: 240.0 minutes [14400 seconds]
Tue Nov 27 12:36:51 2018 [INFO] Waiting 2.0 minutes plus 0 splay seconds [120 seconds total] before performing first auto-attach.
Tue Nov 27 12:36:51 2018 [INFO] Waiting 2.0 minutes plus 0 splay seconds [120 seconds total] before performing first cert check.
Tue Nov 27 12:38:55 2018 [INFO] (Cert Check) Certificates updated.
Tue Nov 27 12:38:57 2018 [INFO] (Auto-attach) Certificates updated.
^C
[root@unused ~]# syspurpose show
{
  "addons": [
    ""
  ],
  "service_level_agreement": "Premium",
  "usage": "QA",
  "role": "RHEL Server"
}

Comment 2 Chris Snyder 2018-12-10 15:47:46 UTC
Please retest with the Snap 3 compose (subman version 1.23.8-6 or greater).

Comment 3 Rehana 2019-01-07 15:40:09 UTC
# subscription-manager version
server type: Red Hat Subscription Management
subscription management server: 2.3.12-1
subscription management rules: 5.30
subscription-manager: 1.23.8-12.el8

[root@kvm-01-guest29 ~]# syspurpose show
{
  "addons": [
    "Addons1",
    "Addons2"
  ],
  "role": "RHEL Server",
  "service_level_agreement": "Self-Support",
  "usage": "QA"
}
System purpose successfully sent to subscription management server.


[root@kvm-01-guest29 ~]# rm -rf /etc/rhsm/syspurpose/syspurpose.json 

[root@kvm-01-guest29 ~]# cat /etc/rhsm/syspurpose/syspurpose.json 
cat: /etc/rhsm/syspurpose/syspurpose.json: No such file or directory

Wait for the certcheck to complete, 

[root@kvm-01-guest29 ~]# tail -f /var/log/rhsm/rhsmcertd.log 
Mon Jan  7 10:33:20 2019 [INFO] (Cert Check) Certificates updated.

[root@kvm-01-guest29 ~]# syspurpose show
{}
System purpose successfully sent to subscription management server.
 
rhsm.log:
========
2019-01-07 10:33:20,548 [DEBUG] rhsmcertd-worker:2599:MainThread @syspurposelib.py:204 - Syspurpose updated: Syspurpose Sync
        status: Successfully synced system purpose
        updates: 'role' removed by change from /etc/rhsm/syspurpose/syspurpose.json
		 'usage' removed by change from /etc/rhsm/syspurpose/syspurpose.json
		 'addons' removed by change from /etc/rhsm/syspurpose/syspurpose.json
		 'service_level_agreement' removed by change from /etc/rhsm/syspurpose/syspurpose.json
        exceptions: 

        
Observed that now the files are not restored , and the syspurpose.json file is set to {} also edits made in the file are not lost after the certcheck

Comment 4 Rehana 2019-01-16 08:02:42 UTC
Verifying on :
=============
# subscription-manager version
server type: Red Hat Subscription Management
subscription management server: 2.3.12-1
subscription management rules: 5.30
subscription-manager: 1.23.8-14.el8

Scenario 1 : Verify the data is NOT restored when syspurpose.json file is deleted 
=============================================================================

Make sure the system is registered and have some syspurpose values set 

# syspurpose show
{
  "addons": [
    "High Availability"
  ],
  "role": "Red Hat Enterprise Linux Server",
  "service_level_agreement": "Premium",
  "usage": "QA"
}
System purpose successfully sent to subscription management server.

Delete the syspurpose.json file and wait for rhsmcertd check to happen

# rm -rf /etc/rhsm/syspurpose/syspurpose.json 


# cat /etc/rhsm/syspurpose/syspurpose.json 
cat: /etc/rhsm/syspurpose/syspurpose.json: No such file or directory

tail rhsmcertd.log
==================
Wed Jan 16 02:48:52 2019 [INFO] Waiting 2.0 minutes plus 0 splay seconds [120 seconds total] before performing first auto-attach.
Wed Jan 16 02:48:52 2019 [INFO] Waiting 2.0 minutes plus 0 splay seconds [120 seconds total] before performing first cert check.
Wed Jan 16 02:50:56 2019 [INFO] (Cert Check) Certificates updated.
Wed Jan 16 02:51:02 2019 [INFO] (Auto-attach) Certificates updated.

rhsm.log 
=========
2019-01-16 02:54:00,591 [DEBUG] rhsmcertd-worker:18292:MainThread @files.py:381 - Successfully updated remote syspurpose on the server.
2019-01-16 02:54:00,591 [DEBUG] rhsmcertd-worker:18292:MainThread @files.py:502 - Successfully updated syspurpose values at '/etc/rhsm/syspurpose/syspurpose.json'.
2019-01-16 02:54:00,591 [DEBUG] rhsmcertd-worker:18292:MainThread @files.py:502 - Successfully updated syspurpose values at '/var/lib/rhsm/cache/syspurpose.json'.
2019-01-16 02:54:00,592 [DEBUG] rhsmcertd-worker:18292:MainThread @files.py:292 - Successfully synced system purpose.
2019-01-16 02:54:00,592 [DEBUG] rhsmcertd-worker:18292:MainThread @syspurposelib.py:204 - Syspurpose updated: Syspurpose Sync
        status: Successfully synced system purpose
        updates: 'usage' removed by change from /etc/rhsm/syspurpose/syspurpose.json
		 'addons' removed by change from /etc/rhsm/syspurpose/syspurpose.json
		 'role' removed by change from /etc/rhsm/syspurpose/syspurpose.json
		 'service_level_agreement' removed by change from /etc/rhsm/syspurpose/syspurpose.json
        exceptions: 


Observed that now the files are not restored , 
# syspurpose show
{}
System purpose successfully sent to subscription management server.



Scenario 2 : Verify the manual edits made in the syspurpose.json file are not lost after the rhsmcert check run
===============================================================================================================
Modify the usage value to"Production" manually
#syspurpose show  

{
  "addons": [
    "High Availability"
  ],
  "role": "Red Hat Enterprise Linux Server",
  "service_level_agreement": "Premium",
  "usage": "QA"
}
System purpose successfully sent to subscription management server.
# vi /etc/rhsm/syspurpose/syspurpose.json 
# cat /etc/rhsm/syspurpose/syspurpose.json 
{
  "addons": [
    "High Availability"
  ],
  "role": "Red Hat Enterprise Linux Server",
  "service_level_agreement": "Premium",
  "usage": "Production" ==> updated to 'Production' manually 
}

Wait for rhsmcert check to happen and Verify the usage is set to the new value  "production"


Based on the above observations , moving the bug to verified .

# cat /etc/rhsm/syspurpose/syspurpose.json 
{
  "addons": [
    "High Availability"
  ],
  "role": "Red Hat Enterprise Linux Server",
  "service_level_agreement": "Premium",
  "usage": "Production"
}[root@kvm-02-guest09 ~]# syspurpose show
{
  "addons": [
    "High Availability"
  ],
  "role": "Red Hat Enterprise Linux Server",
  "service_level_agreement": "Premium",
  "usage": "Production"
}


rhsm.log :
========

2019-01-16 02:57:00,654 [DEBUG] rhsmcertd-worker:18440:MainThread @files.py:292 - Successfully synced system purpose.
2019-01-16 02:57:00,654 [DEBUG] rhsmcertd-worker:18440:MainThread @syspurposelib.py:204 - Syspurpose updated: Syspurpose Sync
        status: Successfully synced system purpose
        updates: 'usage' updated from 'QA' to 'Production' due to change in /etc/rhsm/syspurpose/syspurpose.json
        exceptions: 

Observed that usage is now set to the new value "Production"

Conclusion:
Verifying the bug, based on the results of scenarion 1 and 2 .

Comment 6 Rehana 2020-12-15 09:05:22 UTC
As per Comment 4 , closing the bug as current release


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