Bug 667953

Summary: empty facts.json - unable to register client to Candlepin
Product: Red Hat Enterprise Linux 6 Reporter: Garik Khachikyan <gkhachik>
Component: subscription-managerAssignee: Adrian Likins <alikins>
Status: CLOSED ERRATA QA Contact: John Sefler <jsefler>
Severity: low Docs Contact:
Priority: low    
Version: 6.1CC: alikins, mkoci, spandey
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-05-19 13:38:31 UTC Type: ---
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: 639436    

Description Garik Khachikyan 2011-01-07 12:14:29 UTC
Description of problem:
In my RHEL 6.1 Server x86_64 (can't reproduce how) there appeared empty /var/lib/rhsm/facts/facts.json file there.
and due to this fact subscription-manager failed to "register" to the candlepin server specified.
Message printed:
---
No JSON object could be decoded
---

And after this the file still remains not filled.

Version-Release number of selected component (if applicable):
git pull of subscription-manager from Jan.07.2011 12PM CET

How reproducible:
always

Steps to Reproduce:
0. modify the rhsm.conf
1. git clone subscription-manager; cd subscription-manager
2. PYTHONPATH=src; 
3. empty content of /var/lib/rhsm/facts/facts.json
4. run: src/subscription-manager register --username=admin --password=admin
  
Actual results:
No JSON object could be decoded

Expected results:
the code should see if the file is broken (empty for my case) and reload the HW info and overwrite the file there.

Additional info:
traceback of vim /var/log/rhsm/rhsm.log:
---
2011-01-07 13:10:18,743 [ERROR] handle_exception() @managercli.py:44 - exception caught in subscription-manager
2011-01-07 13:10:18,744 [ERROR] handle_exception() @managercli.py:45 - No JSON object could be decoded
Traceback (most recent call last):
  File "src/subscription-manager", line 75, in <module>
    sys.exit(abs(main() or 0))
  File "src/subscription-manager", line 66, in main
    return managercli.CLI().main()
  File "/root/subscription-manager/src/managercli.py", line 722, in main
    cmd.main()
  File "/root/subscription-manager/src/managercli.py", line 150, in main
    self._do_command()
  File "/root/subscription-manager/src/managercli.py", line 335, in _do_command
    facts=self.facts.get_facts())
  File "/root/subscription-manager/src/facts.py", line 90, in get_facts
    self.facts = self.find_facts()
  File "/root/subscription-manager/src/facts.py", line 113, in find_facts
    self.write(facts)
  File "/root/subscription-manager/src/facts.py", line 29, in write
    existing_facts = self.read()
  File "/root/subscription-manager/src/facts.py", line 42, in read
    cached_facts = json.loads(json_buffer)
  File "/usr/lib64/python2.6/site-packages/simplejson/__init__.py", line 307, in loads
    return _default_decoder.decode(s)
  File "/usr/lib64/python2.6/site-packages/simplejson/decoder.py", line 335, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib64/python2.6/site-packages/simplejson/decoder.py", line 353, in raw_decode
    raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded

Comment 6 Adrian Likins 2011-01-07 17:14:29 UTC
commit 9bab7c02d438ed77fb6b3437d9e811deacc2a7ae
Author: Adrian Likins <alikins>
Date:   Fri Jan 7 12:11:14 2011 -0500

    667953: handle empty facts.json files
    
    Print out a warning, but otherwise keep going.

Comment 7 John Sefler 2011-01-12 21:13:04 UTC
Adrian - the following traceback was being swallowed by by handle_exception in managercli.py
Movving back to ON_DEV

Traceback (most recent call last):
  File "/usr/sbin/subscription-manager", line 76, in <module>
    sys.exit(abs(main() or 0))
  File "/usr/sbin/subscription-manager", line 67, in main
    return managercli.CLI().main()
  File "/usr/share/rhsm/managercli.py", line 730, in main
    cmd.main()
  File "/usr/share/rhsm/managercli.py", line 155, in main
    self._do_command()
  File "/usr/share/rhsm/managercli.py", line 340, in _do_command
    facts=self.facts.get_facts())
  File "/usr/share/rhsm/facts.py", line 92, in get_facts
    self.facts = self.find_facts()
  File "/usr/share/rhsm/facts.py", line 115, in find_facts
    self.write(facts)
  File "/usr/share/rhsm/facts.py", line 29, in write
    existing_facts = self.read()
  File "/usr/share/rhsm/facts.py", line 42, in read
    cached_facts = json.loads(json_buffer)
  File "/usr/lib64/python2.6/site-packages/simplejson/__init__.py", line 307, in loads
    return _default_decoder.decode(s)
  File "/usr/lib64/python2.6/site-packages/simplejson/decoder.py", line 335, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib64/python2.6/site-packages/simplejson/decoder.py", line 353, in raw_decode
    raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded

Comment 8 John Sefler 2011-01-12 21:29:25 UTC
A fix is also needed for related bugzilla #669208
The re-create scenario is identical.

Comment 9 Adrian Likins 2011-01-13 17:02:05 UTC
commit dd5ab27f904413a8796da5abc41a7c5912a561b0
Author: Adrian Likins <alikins>
Date:   Wed Jan 12 15:04:44 2011 -0500

    667953: remove warning here about empty facts.json
    
    This is not a useful warning and can be totally ignored, so
    lets get rid of it.


Between this and the fix for #669208, this should be fixed now.

Comment 10 spandey 2011-01-20 12:06:13 UTC
Tested with IT env and premises candlepin with empty facts.json file 

Verify using following subscription manager rpm 

subscription-manager-firstboot-0.93.13-1.el6.x86_64
subscription-manager-0.93.13-1.el6.x86_64
subscription-manager-gnome-0.93.13-1.el6.x86_64

Successfully registered to IT ENV 
No error message displayed on console
No error message recored in rhsm.log 


Successfully registered to premises 
No error message displayed on console
No error message recored in rhsm.log 


Working fine Moving defect status from ON_QA to Verified

Comment 11 errata-xmlrpc 2011-05-19 13:38:31 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHEA-2011-0611.html