Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1870567: Fix issue with locale and D-Bus method GetStatus; ENT-2772 #2321

Merged
merged 1 commit into from Sep 10, 2020

Conversation

jirihnidek
Copy link
Contributor

  • BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1870567
  • There were three reasons, why locale og GetStatus returned
    strings with wrong locale
    • REST API calls were called with wrong Accept-Language header,
      because the header was set for session and it was used for
      all REST API calls
    • Some strings (e.g. "Invalid") were translated during start
      of rhsm.service according system settings of locale and then
      these translated strings were used
    • Some strings are translated on candlepin server. Unfortunately
      some translated strings were saved in cache files and strings
      with unwanted translations were returned by GetStatus method
  • So, some global variables with translated strings were moved
    to methods. Thus these strings are translated everytime, when
    method si called
  • Caching of /var/lib/rhsm/cache/entitlement_status.json is
    disabled for rhsm.service to avoid returning strings with
    unwanted translation
  • HTTP header with Accept-Language is set for every REST API call
  • JSON document returned by GetStatus method was extended. So
    it includes now "status_id" and "reason_ids" with untranslated
    reasons. It can be used for checks in code.
  • Modified and extended some unit tests

@jirihnidek
Copy link
Contributor Author

Example how to test it:

[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\": \"Invalide\", \"status_id\": \"invalid\", \"reasons\": {\"Fake OS Bits\": [\"Non pris en charge par un abonnement valide.\"], \"SP Server Bits\": [\"Non pris en charge par un abonnement valide.\"]}, \"reason_ids\": {\"38072\": [{\"key\": \"NOTCOVERED\", \"product_name\": \"Fake OS Bits\"}], \"99000\": [{\"key\": \"NOTCOVERED\", \"product_name\": \"SP Server Bits\"}]}, \"valid\": false}"
[root@thinkpad-t580 subscription-manager]# 
[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\": \"Inv\\u00e1lido\", \"status_id\": \"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\"]}, \"reason_ids\": {\"99000\": [{\"key\": \"NOTCOVERED\", \"product_name\": \"SP Server Bits\"}], \"38072\": [{\"key\": \"NOTCOVERED\", \"product_name\": \"Fake OS Bits\"}]}, \"valid\": false}"

@wottop
Copy link
Member

wottop commented Aug 27, 2020

buildbot: retest this please

@jirihnidek jirihnidek force-pushed the jhnidek/1870567 branch 2 times, most recently from 31b5bb7 to 91ff178 Compare September 2, 2020 09:37
@wottop
Copy link
Member

wottop commented Sep 4, 2020

Passed my functional tests. It needs automated tests to succeed and a squash.

@wottop wottop self-assigned this Sep 4, 2020
* BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1870567
* There were three reasons, why locale og GetStatus returned
  strings with wrong locale
  * REST API calls were called with wrong Accept-Language header,
    because the header was set for session and it was used for
    all REST API calls
  * Some strings (e.g. "Invalid") were translated during start
    of rhsm.service according system settings of locale and then
    these translated strings were used
  * Some strings are translated on candlepin server. Unfortunately
    some translated strings were saved in cache files and strings
    with unwanted translations were returned by GetStatus method
* So, some global variables with translated strings were moved
  to methods. Thus these strings are translated everytime, when
  method si called
* Caching of /var/lib/rhsm/cache/entitlement_status.json is
  disabled for rhsm.service to avoid returning strings with
  unwanted translation
* HTTP header with Accept-Language is set for every REST API call
* JSON document returned by GetStatus method was extended. So
  it includes now "status_id" and "reason_ids" with untranslated
  reasons. It can be used for checks in code.
* Modified our cockpit plugin to use new D-Bus API
* Modified and extended some unit tests
@wottop
Copy link
Member

wottop commented Sep 10, 2020

final ack

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants