Bug 1702239

Summary: Syspurpose command shows Python traceback, when locale is not supported
Product: Red Hat Enterprise Linux 7 Reporter: Jiri Hnidek <jhnidek>
Component: subscription-managerAssignee: Jiri Hnidek <jhnidek>
Status: CLOSED ERRATA QA Contact: Red Hat subscription-manager QE Team <rhsm-qe>
Severity: high Docs Contact:
Priority: high    
Version: 7.7CC: awood, csnyder, dranck, jomurphy, jsefler, ktordeur, nmoumoul, skallesh
Target Milestone: rcKeywords: Triaged
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: subscription-manager-1.24.14-1.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-03-31 19:40:52 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: 1704281    

Description Jiri Hnidek 2019-04-23 09:54:34 UTC
Description of problem:
When system has set some unsupported locale (e.g. Czech language), then syspurpose command shows Python traceback for every syspurpose command.

Version-Release number of selected component (if applicable):
[root@localhost ~]# subscription-manager version
server type: Red Hat Subscription Management
subscription management server: 2.7.0-1
subscription management rules: 5.36
subscription-manager: 1.25.1-1.git.45.9ffd59c.fc29

How reproducible:
100%

Steps to Reproduce:
1. Set locale that is not supported by subscription-manager e.g. Czech language

[root@localhost ~]# export LANG=cs_CZ.utf8

2. Run any syspurpose command:

[root@localhost ~]# syspurpose show

Actual results:

Traceback (most recent call last):
  File "/usr/lib64/python2.7/logging/__init__.py", line 851, in emit
    msg = self.format(record)
  File "/usr/lib64/python2.7/logging/__init__.py", line 724, in format
    return fmt.format(record)
  File "/usr/lib64/python2.7/logging/__init__.py", line 467, in format
    s = self._fmt % record.__dict__
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 105: ordinal not in range(128)
Logged from file identity.py, line 149
{
  "role": "RHEL Server", 
}

Expected results: Output without traceback

Logged from file identity.py, line 149
{
  "role": "RHEL Server", 

}

Additional info:
This bug is propabaly Python2 specific, because it works as expected, when Python3 is used e.g. on Fedora.

Comment 2 Alex Wood 2019-05-02 20:20:18 UTC
I wasn't able to reproduce this issue.  Let me get a little more information from you.

* I was running my test on Centos7.  What distro were you using?
* Is that the full stack trace?  It looks like it but it seems curious that it doesn't reference any lines from subscription-manager
* Since the stacktrace is referencing the logging library, can you paste the last few lines of log output?  Maybe that would help narrow down the search space.

Comment 3 Jiri Hnidek 2019-05-03 07:36:02 UTC
Hi Al,
I'm sorry. I missed the important information in bug report. I'm able to reproduce the bug, when the system is NOT registered. I'm not able to reproduce the bug, when system is registered.

* I was using CentOS 7 distro too.
* The stack trace is full. It is really strange that there is no reference from subscription-manager.
* There is log (rhsm.log) output:

2019-05-03 07:22:35,495 [DEBUG] syspurpose:4370:MainThread @cli.py:296 - Running the syspurpose utility...
2019-05-03 07:22:35,505 [DEBUG] syspurpose:4370:MainThread @identity.py:138 - Loading consumer info from identity certificates.
2019-05-03 07:22:35,506 [DEBUG] syspurpose:4370:MainThread @connection.py:924 - Connection built: host=svice port=8443 handler=/candlepin auth=identity_cert ca_dir=/etc/rhsm/ca/ insecure=True
2019-05-03 07:22:35,507 [DEBUG] syspurpose:4370:MainThread @files.py:319 - Successfully read local syspurpose contents.
2019-05-03 07:22:35,507 [DEBUG] syspurpose:4370:MainThread @files.py:356 - Successfully read cached syspurpose contents.
2019-05-03 07:22:35,507 [DEBUG] syspurpose:4370:MainThread @files.py:273 - Attempting to sync syspurpose content...
2019-05-03 07:22:35,508 [DEBUG] syspurpose:4370:MainThread @connection.py:591 - Making request: GET /candlepin/status
2019-05-03 07:22:35,520 [DEBUG] syspurpose:4370:MainThread @connection.py:638 - Response: status=200, requestUuid=695b6015-05a1-4e70-8751-cd3eddc6c5d8, request="GET /candlepin/status"
2019-05-03 07:22:35,521 [DEBUG] syspurpose:4370:MainThread @connection.py:977 - Server has the following capabilities: [u'instance_multiplier', u'derived_product', u'vcpu', u'cert_v3', u'remove_by_pool_id', u'syspurpose', u'storage_band', u'cores', u'hypervisors_async', u'org_level_content_access', u'guest_limit', u'ram', u'batch_bind']
2019-05-03 07:22:35,522 [DEBUG] syspurpose:4370:MainThread @files.py:334 - Failed to read remote syspurpose from server: no available connection, or the consumer is not registered.
2019-05-03 07:22:35,526 [DEBUG] syspurpose:4370:MainThread @files.py:552 - Attempting a three-way merge...
2019-05-03 07:22:35,527 [DEBUG] syspurpose:4370:MainThread @files.py:373 - Failed to update remote syspurpose on the server: no available connection, or the consumer is not registered.
2019-05-03 07:22:35,533 [DEBUG] syspurpose:4370:MainThread @files.py:506 - Successfully updated syspurpose values at '/etc/rhsm/syspurpose/syspurpose.json'.
2019-05-03 07:22:35,537 [DEBUG] syspurpose:4370:MainThread @files.py:506 - Successfully updated syspurpose values at '/var/lib/rhsm/cache/syspurpose.json'.
2019-05-03 07:22:35,538 [DEBUG] syspurpose:4370:MainThread @files.py:296 - Successfully synced system purpose.

Comment 5 Jiri Hnidek 2019-05-21 13:39:46 UTC
I forgot to mention the last important detail. The option default_log_level has to be set to "DEBUG" in rhsm.conf.

Comment 7 Shwetha Kallesh 2019-05-30 14:49:56 UTC
Reproducer:

[root@kvm-01-guest10 ~]# subscription-manager version
server type: This system is currently not registered.
subscription management server: 2.3.17-1
subscription management rules: 5.35
subscription-manager: 1.25.1-1.git.78.8ae61ee.el7


[root@kvm-01-guest10 ~]# LANG=cs_CZ.utf8 syspurpose show
Traceback (most recent call last):
  File "/usr/lib64/python2.7/logging/__init__.py", line 851, in emit
    msg = self.format(record)
  File "/usr/lib64/python2.7/logging/__init__.py", line 724, in format
    return fmt.format(record)
  File "/usr/lib64/python2.7/logging/__init__.py", line 467, in format
    s = self._fmt % record.__dict__
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 105: ordinal not in range(128)
Logged from file identity.py, line 149

Comment 8 Chris Snyder 2019-05-30 17:44:29 UTC
This was added by mistake to the errata. The latest build of subscription-manager does not include this bug fix. Moving back to POST (as the fix has been completed upstream but not downstream).

Comment 14 Shwetha Kallesh 2019-09-11 09:53:40 UTC
reproducer:

[root@hpe-dl360egen8-01 ~]# subscription-manager version
server type: This system is currently not registered.
subscription management server: 2.7.5-1
subscription management rules: 5.37
subscription-manager: 1.24.13-1.el7


[root@hpe-dl360egen8-01 ~]# syspurpose set-usage foo
usage set to foo
Unable to send system purpose to subscription management server
[root@hpe-dl360egen8-01 ~]# vi /etc/rhsm/rhsm.conf 
[root@hpe-dl360egen8-01 ~]# export LANG=cs_CZ.utf8
[root@hpe-dl360egen8-01 ~]# syspurpose show
Traceback (most recent call last):
  File "/usr/lib64/python2.7/logging/__init__.py", line 851, in emit
    msg = self.format(record)
  File "/usr/lib64/python2.7/logging/__init__.py", line 724, in format
    return fmt.format(record)
  File "/usr/lib64/python2.7/logging/__init__.py", line 467, in format
    s = self._fmt % record.__dict__
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 105: ordinal not in range(128)
Logged from file identity.py, line 149

{
  "usage": "foo"
}
Unable to send system purpose to subscription management server

Comment 15 Shwetha Kallesh 2019-09-11 09:56:02 UTC
[root@hpe-dl360gen8-01 ~]# subscription-manager version
server type: This system is currently not registered.
subscription management server: 2.7.5-1
subscription management rules: 5.37
subscription-manager: 1.24.17-1.el7


Verification:

[root@hpe-dl360gen8-01 ~]# subscription-manager unregister
Unregistering from: subscription.rhsm.stage.redhat.com:443/subscription
System has been unregistered.


[root@hpe-dl360gen8-01 ~]# cat /etc/rhsm/rhsm.conf | grep log
[logging]
default_log_level = DEBUG


[root@hpe-dl360gen8-01 ~]# export LANG=cs_CZ.utf8
[root@hpe-dl360gen8-01 ~]# syspurpose show
{
  "role": "dsadsa"
}

Comment 17 errata-xmlrpc 2020-03-31 19:40:52 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, 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-2020:1028