Bug 1870567

Summary: Method GetStatus provided by rhsm.service returns strings with wrong localization
Product: Red Hat Enterprise Linux 8 Reporter: Jiri Hnidek <jhnidek>
Component: subscription-managerAssignee: Jan Stavel <jstavel>
Status: CLOSED ERRATA QA Contact: Red Hat subscription-manager QE Team <rhsm-qe>
Severity: low Docs Contact:
Priority: high    
Version: 8.2CC: bcourt, jsefler, jstavel, ktordeur, redakkan
Target Milestone: rcKeywords: Triaged
Target Release: 8.4Flags: pm-rhel: mirror+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-05-18 13:33:55 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: 1796916, 1870837    

Description Jiri Hnidek 2020-08-20 11:43:39 UTC
Description of problem:
When locate of system is set to e.g. en_EN.UTF-8, then D-Bus method GetStatus provided by rhsm.service returns status in English language and locale string used in GetStatus method is ignored

Version-Release number of selected component (if applicable):
[root@rhel82 ~]# subscription-manager version
server type: Red Hat Subscription Management
subscription management server: 3.1.16-1
subscription management rules: 5.40
subscription-manager: 1.26.17-1.el8_2

How reproducible:
100%

Steps to Reproduce:
1. Ensure that English language is used as system locale

[root@rhel82 ~]# localectl 
   System Locale: LANG=en_US.UTF-8
       VC Keymap: us
      X11 Layout: us


2. Make sure that rhsm.service is running

[root@rhel82 ~]# systemctl restart rhsm.service 
[root@rhel82 ~]# systemctl status rhsm.service 
● rhsm.service - RHSM dbus service
   Loaded: loaded (/usr/lib/systemd/system/rhsm.service; disabled; vendor preset: disabled)
   Active: active (running) since Thu 2020-08-20 13:05:34 CEST; 3s ago
 Main PID: 42272 (rhsm-service)
    Tasks: 2 (limit: 11339)
   Memory: 28.7M
   CGroup: /system.slice/rhsm.service
           └─42272 /usr/libexec/platform-python /usr/libexec/rhsm-service

Aug 20 13:05:34 rhel82 rhsm-service[42272]: DEBUG [rhsm.https:56] Using standard libs to provide httplib and ssl
Aug 20 13:05:34 rhel82 rhsm-service[42272]: DEBUG [rhsmlib.dbus.service_wrapper:66] Starting DBus service with name com.redhat.RHSM1
Aug 20 13:05:34 rhel82 rhsm-service[42272]: DEBUG [subscription_manager.identity:139] Loading consumer info from identity certificates.
Aug 20 13:05:34 rhel82 systemd[1]: Started RHSM dbus service.
Aug 20 13:05:34 rhel82 rhsm-service[42272]: DEBUG [rhsmlib.dbus.server:182] Start notification sent
Aug 20 13:05:34 rhel82 rhsm-service[42272]: DEBUG [rhsmlib.file_monitor:201] Added i-notifier watcher for: /etc/pki/consumer with mask: 642
Aug 20 13:05:34 rhel82 rhsm-service[42272]: DEBUG [rhsmlib.file_monitor:201] Added i-notifier watcher for: /etc/pki/entitlement with mask: 642
Aug 20 13:05:34 rhel82 rhsm-service[42272]: DEBUG [rhsmlib.file_monitor:201] Added i-notifier watcher for: /etc/rhsm/rhsm.conf with mask: 642
Aug 20 13:05:34 rhel82 rhsm-service[42272]: DEBUG [rhsmlib.file_monitor:201] Added i-notifier watcher for: /etc/pki/product with mask: 642
Aug 20 13:05:34 rhel82 rhsm-service[42272]: DEBUG [rhsmlib.file_monitor:201] Added i-notifier watcher for: /etc/rhsm/syspurpose/syspurpose.json with mask: 642


3. Try to get system status using D-Bus method GetStatus using several different locales:

[root@rhel82 ~]# busctl call com.redhat.RHSM1 /com/redhat/RHSM1/Entitlement com.redhat.RHSM1.Entitlement GetStatus ss "" "es_ES.UTF-8"
s "{\"status\": \"Current\", \"reasons\": {}, \"valid\": true}"  <===== status is "Current" (string with English locale is returned)

[root@rhel82 ~]# busctl call com.redhat.RHSM1 /com/redhat/RHSM1/Entitlement com.redhat.RHSM1.Entitlement GetStatus ss "" "fr_FR.UTF-8"
s "{\"status\": \"Current\", \"reasons\": {}, \"valid\": true}"  <===== status is "Current" (string with English locale is returned)


4. Try to get status using subscription-manager using and different LANG environment variables

[root@rhel82 ~]# LANG="es_ES.UTF-8" subscription-manager status
You are attempting to use a locale that is not installed.
+-------------------------------------------+
   Información de estatus del sistema
+-------------------------------------------+
Overall Status: Actual  <===== Status is translated to Spanish

System Purpose Status: Not Specified

[root@rhel82 ~]# LANG="fr_FR.UTF-8" subscription-manager status
You are attempting to use a locale that is not installed.
+-------------------------------------------+
   Détails du statut du système
+-------------------------------------------+
Overall Status: Actuel  <===== Status is translated to French

System Purpose Status: Not Specified



Actual results:
GetStatus returns status with locale that is specified for the system.

Expected results:
GetStatus should return status with locale specified in D-Bus method call

Additional info:

It also seems that some localized messages are saved in our cache files. This case was tested on Fedora, but I believe that we can observer similar behavior on RHEL8.2

1. Remove all pools:
[root@thinkpad-t580 ~]# subscription-manager remove --all


2. Delete cache file:
[root@thinkpad-t580 ~]# rm -f /var/lib/rhsm/cache/entitlement_status.json


3. Restart rhsm service:
[root@thinkpad-t580 ~]# systemctl restart rhsm.service


4. Try to get status using Spanish locale:
[root@thinkpad-t580 subscription-manager]# busctl call com.redhat.RHSM1 /com/redhat/RHSM1/Entitlement com.redhat.RHSM1.Entitlement GetStatus ss "" "es_ES.UTF-8"
s "{\"status\": \"Invalid\", \"reasons\": {\"SP Server Bits\": [\"No est\\u00e1 soportado por una suscripci\\u00f3n v\\u00e1lida\"], \"Fake OS Bits\": [\"No est\\u00e1 soportado por una suscripci\\u00f3n v\\u00e1lida\"]}, \"valid\": false}"

^
Reasons are in Spanish locale

4. Try to get status using French locale:
[root@thinkpad-t580 subscription-manager]# busctl call com.redhat.RHSM1 /com/redhat/RHSM1/Entitlement com.redhat.RHSM1.Entitlement GetStatus ss "" "fr_FR.UTF-8"
s "{\"status\": \"Invalid\", \"reasons\": {\"SP Server Bits\": [\"No est\\u00e1 soportado por una suscripci\\u00f3n v\\u00e1lida\"], \"Fake OS Bits\": [\"No est\\u00e1 soportado por una suscripci\\u00f3n v\\u00e1lida\"]}, \"valid\": false}"

^
Reasons are in still in Spanish locale


5. You can see that entitlement status is cached and it contains Spanish strings:
[root@thinkpad-t580 subscription-manager]# cat /var/lib/rhsm/cache/entitlement_status.json | python -m json.tool
{
    "status": "invalid",
    "compliant": false,
    "date": "2020-08-20T11:35:46+0000",
    "compliantUntil": null,
    "compliantProducts": {},
    "nonCompliantProducts": [
        "99000",
        "38072"
    ],
    "partiallyCompliantProducts": {},
    "partialStacks": {},
    "productComplianceDateRanges": {},
    "reasons": [
        {
            "key": "NOTCOVERED",
            "message": "No est\u00e1 soportado por una suscripci\u00f3n v\u00e1lida",
            "attributes": {
                "name": "SP Server Bits",
                "product_id": "99000"
            }
        },
        {
            "key": "NOTCOVERED",
            "message": "No est\u00e1 soportado por una suscripci\u00f3n v\u00e1lida",
            "attributes": {
                "name": "Fake OS Bits",
                "product_id": "38072"
            }
        }
    ]
}

Comment 2 Jan Stavel 2020-10-13 08:19:28 UTC
It seems to me that the latest rpms work as described here - ie. status value is localized regarding to requested locale.

Comment 3 Jan Stavel 2020-11-04 16:26:18 UTC
[root@kvm-03-guest02 ~]# rpm -qa | egrep 'subscription|rhsm|cockpit|syspurpose'
subscription-manager-1.28.5-1.el8.x86_64
subscription-manager-rhsm-certificates-1.28.5-1.el8.x86_64
python3-subscription-manager-rhsm-1.28.5-1.el8.x86_64
dnf-plugin-subscription-manager-1.28.5-1.el8.x86_64
python3-syspurpose-1.28.5-1.el8.x86_64
librhsm-0.0.3-3.el8.x86_64



[root@kvm-03-guest02 ~]# subscription-manager register --auto-attach
Registering to: subscription.rhsm.stage.redhat.com:443/subscription
Username: jstavel_stage_demo01
Password:
The system has been registered with ID: 2d168e48-1ccc-47e5-b3ff-18801f26139f                                                                           
The registered system name is: kvm-03-guest02.hv2.lab.eng.bos.redhat.com
Installed Product Current Status:
Product Name: Red Hat Enterprise Linux for x86_64 Beta
Status:       Subscribed

[root@kvm-03-guest02 ~]# LANG=es_ES.UTF-8 subscription-manager status                                                                                  
You are attempting to use a locale: "es_ES.UTF-8" that is not fully supported by this system.                                                          
+-------------------------------------------+
   Información de estatus del sistema
+-------------------------------------------+
Estado general: Actual

System Purpose Status: Not Specified

[root@kvm-03-guest02 ~]# busctl call com.redhat.RHSM1 /com/redhat/RHSM1/Entitlement com.redhat.RHSM1.Entitlement GetStatus ss "" "es_ES.UTF-8"         
s "{\"status\": \"Actual\", \"status_id\": \"valid\", \"reasons\": {}, \"reason_ids\": {}, \"valid\": true}"                                           

[root@kvm-03-guest02 ~]# busctl call com.redhat.RHSM1 /com/redhat/RHSM1/Entitlement com.redhat.RHSM1.Entitlement GetStatus ss "" "jp_JP.UTF-8"
s "{\"status\": \"\\u6700\\u65b0\", \"status_id\": \"valid\", \"reasons\": {}, \"reason_ids\": {}, \"valid\": true}"

[root@kvm-03-guest02 ~]# busctl call com.redhat.RHSM1 /com/redhat/RHSM1/Entitlement com.redhat.RHSM1.Entitlement GetStatus ss "" "en_US.UTF-8"
s "{\"status\": \"Current\", \"status_id\": \"valid\", \"reasons\": {}, \"reason_ids\": {}, \"valid\": true}"

[root@kvm-03-guest02 ~]# busctl call com.redhat.RHSM1 /com/redhat/RHSM1/Entitlement com.redhat.RHSM1.Entitlement GetStatus ss "" "es_ES.UTF-8"
s "{\"status\": \"Actual\", \"status_id\": \"valid\", \"reasons\": {}, \"reason_ids\": {}, \"valid\": true}"

Comment 4 Rehana 2020-11-05 08:54:12 UTC
Based on comment 3, setting Verified field to tested.

Comment 7 Jan Stavel 2020-11-20 15:36:21 UTC
I've verified that 
- method GetStatus returns localized message.

- reasons of an uncovered product are provided in the proper language



[root@localhost ~]# LANG="fr_FR.UTF-8" subscription-manager status
You are attempting to use a locale: "fr_FR.UTF-8" that is not fully supported by this system.
+-------------------------------------------+
   Détails du statut du système
+-------------------------------------------+
Statut général : Actuel

System Purpose Status: Not Specified

[root@localhost ~]# subscription-manager remove --all
1 local certificate has been deleted.
1 subscription removed at the server.

[root@localhost ~]# rm -f /var/lib/rhsm/cache/entitlement_status.json 
[root@localhost ~]# systemctl restart rhsm.service

[root@localhost ~]# busctl call com.redhat.RHSM1 /com/redhat/RHSM1/Entitlement com.redhat.RHSM1.Entitlement GetStatus ss "" "es_ES.UTF-8"
s "{\"status\": \"Inv\\u00e1lido\", \"status_id\": \"invalid\", \"reasons\": {\"Red Hat Enterprise Linux for x86_64 Beta\": [\"No est\\u00e1 soportado por una suscripci\\u00f3n v\\u00e1lida\"]}, \"reason_ids\": {\"486\": [{\"key\": \"NOTCOVERED\", \"product_name\": \"Red Hat Enterprise Linux for x86_64 Beta\"}]}, \"valid\": false}"

[root@localhost ~]# busctl call com.redhat.RHSM1 /com/redhat/RHSM1/Entitlement com.redhat.RHSM1.Entitlement GetStatus ss "" "fr_FR.UTF-8"
s "{\"status\": \"Invalide\", \"status_id\": \"invalid\", \"reasons\": {\"Red Hat Enterprise Linux for x86_64 Beta\": [\"Non pris en charge par un abonnement valide.\"]}, \"reason_ids\": {\"486\": [{\"key\": \"NOTCOVERED\", \"product_name\": \"Red Hat Enterprise Linux for x86_64 Beta\"}]}, \"valid\": false}"






[root@localhost ~]# rpm -qa | egrep 'subscription|cockpit|syspurpose|rhsm'
subscription-manager-cockpit-1.28.5-1.el8.noarch
cockpit-ws-224.2-1.el8.x86_64
python3-syspurpose-1.28.5-1.el8.x86_64
cockpit-bridge-224.2-1.el8.x86_64
subscription-manager-initial-setup-addon-1.28.5-1.el8.x86_64
rhsm-icons-1.28.5-1.el8.noarch
python3-subscription-manager-rhsm-1.28.5-1.el8.x86_64
cockpit-packagekit-224.2-1.el8.noarch
dnf-plugin-subscription-manager-1.28.5-1.el8.x86_64
cockpit-224.2-1.el8.x86_64
subscription-manager-rhsm-certificates-1.28.5-1.el8.x86_64
librhsm-0.0.3-3.el8.x86_64
rhsm-gtk-1.28.5-1.el8.x86_64
cockpit-system-224.2-1.el8.noarch
subscription-manager-1.28.5-1.el8.x86_64
cockpit-storaged-224.2-1.el8.noarch
cockpit-podman-25-3.module+el8.3.1+8686+2a59bca3.noarch

Comment 9 errata-xmlrpc 2021-05-18 13:33:55 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-2021:1575