Bug 966747
| Summary: | empty and malformed custom facts makes subscription-manager unusable because "No JSON object could be decoded" | ||
|---|---|---|---|
| Product: | Red Hat Enterprise Linux 5 | Reporter: | John Sefler <jsefler> |
| Component: | subscription-manager | Assignee: | Adrian Likins <alikins> |
| Status: | CLOSED ERRATA | QA Contact: | IDM QE LIST <seceng-idm-qe-list> |
| Severity: | medium | Docs Contact: | |
| Priority: | unspecified | ||
| Version: | 5.10 | CC: | alikins, jesusr |
| Target Milestone: | rc | ||
| Target Release: | --- | ||
| Hardware: | Unspecified | ||
| OS: | Unspecified | ||
| Whiteboard: | |||
| Fixed In Version: | Doc Type: | Bug Fix | |
| Doc Text: |
No description necessary
|
Story Points: | --- |
| Clone Of: | Environment: | ||
| Last Closed: | 2013-09-30 23:10:08 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: | 840995 | ||
|
Description
John Sefler
2013-05-23 20:39:35 UTC
... and when custom facts are truely malformed by accident, we fail with the same message:
[root@rhsm-compat-rhel59 ~]# cat /etc/rhsm/facts/malformed.facts
{ "mycustomfacts":"true", "are_malformed":burp}
[root@rhsm-compat-rhel59 ~]# subscription-manager register
Username: testuser1
Password:
No JSON object could be decoded
It would be better to inform the user why/where "No JSON object could be decoded". Something like this....
[root@rhsm-compat-rhel59 ~]# subscription-manager register
Username: testuser1
Password:
Error: Custom facts file "/etc/rhsm/facts/malformed.facts" is not in the proper JSON format. It must be corrected or deleted.
This request was evaluated by Red Hat Product Management for inclusion in a Red Hat Enterprise Linux release. Product Management has requested further review of this request by Red Hat Engineering, for potential inclusion in a Red Hat Enterprise Linux release for currently deployed products. This request is not yet committed for inclusion in a release. https://github.com/candlepin/subscription-manager/pull/628 commit d3be82c492718b9d3e5559e564dc81290e1fcd21 Author: Adrian Likins <alikins> Date: Tue Jun 4 13:02:42 2013 -0400 966747: handle a custom facts file being empty json.loads("") throws a ValueError, so handle that case Add log.info about which custom facts we are loading. Split up custom cache loading into a few methods, so we can test them easier, and add corresponding tests. Add lots more tests to test_facts.py, and fix up some of the issue found. Handle facts cache file not existing, being empty, or otherwise failing to load so Facts.has_changed does the right thing. merged in master with: commit d3be82c492718b9d3e5559e564dc81290e1fcd21 Author: Adrian Likins <alikins> Date: Tue Jun 4 13:02:42 2013 -0400 should be in 1.8.11 Testing Version... [root@jsefler-5 ~]# rpm -q subscription-manager subscription-manager-1.8.10-1.git.15.4bb4042.el5 The fixed behavior appears to log a warning to rhsm.log for the malformed custom facts and proceeds with the subscription-manager task at hand. 2013-06-07 13:31:08,916 [WARNING] @facts.py:125 - Unable to load custom facts file: /etc/rhsm/facts/malformed.facts Verifying Version...
[root@jsefler-5 ~]# rpm -q subscription-manager
subscription-manager-1.8.11-1.el5
Testing empty facts file case...
[root@jsefler-5 ~]# touch /etc/rhsm/facts/empty.facts
[root@jsefler-5 ~]# ls -l /etc/rhsm/facts/
total 4
-rw-r--r-- 1 root root 0 Jul 1 14:44 empty.facts
[root@jsefler-5 ~]# subscription-manager register
Username: testuser1
Password:
Organization: admin
The system has been registered with ID: c2137292-02ef-40ed-8fc9-a8ce390733d3
[root@jsefler-5 ~]#
VERIFIED
Testing malformaed facts file case...
[root@jsefler-5 ~]# subscription-manager unregister
System has been unregistered.
[root@jsefler-5 ~]# echo '{"mycustomfacts":"true", "are_malformed":burp}' > /etc/rhsm/facts/malformed.facts
[root@jsefler-5 ~]# ls -l /etc/rhsm/facts/
total 12
-rw-r--r-- 1 root root 0 Jul 1 14:44 empty.facts
-rw-r--r-- 1 root root 47 Jul 1 14:47 malformed.facts
[root@jsefler-5 ~]# subscription-manager register
Username: testuser1
Password:
Organization: admin
The system has been registered with ID: ff865f17-bddd-4a34-988a-c940911c1a93
[root@jsefler-5 ~]#
VERIFIED
Additional Info...
[root@jsefler-5 ~]# subscription-manager facts --update
Successfully updated the system facts.
[root@jsefler-5 ~]# tail -100 /var/log/rhsm/rhsm.log | grep WARNING
2013-07-01 14:57:56,903 [WARNING] @facts.py:111 - Unable to load custom facts file: /etc/rhsm/facts/malformed.facts
2013-07-01 14:57:56,903 [WARNING] @facts.py:111 - Unable to load custom facts file: /etc/rhsm/facts/empty.facts
[root@jsefler-5 ~]#
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. http://rhn.redhat.com/errata/RHBA-2013-1332.html |