Bug 1093382 - local variable 'dest_fo' referenced before assignment
Summary: local variable 'dest_fo' referenced before assignment
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: subscription-manager
Version: 5.11
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Bryan Kearney
QA Contact: John Sefler
URL:
Whiteboard:
Depends On:
Blocks: rhsm-rhel511
TreeView+ depends on / blocked
 
Reported: 2014-05-01 14:56 UTC by John Sefler
Modified: 2014-09-16 00:22 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2014-09-16 00:22:57 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2014:1225 0 normal SHIPPED_LIVE subscription-manager bug fix and enhancement update 2014-09-16 04:15:23 UTC

Description John Sefler 2014-05-01 14:56:07 UTC
Description of problem:
rhsm-debug system is throwing a traceback for the following negative testcase that tries to call rhsm-debug system --destination=/tmp/foofile where /tmp/foofile exists but is not a directory.


Version-Release number of selected component (if applicable):
[root@jsefler-5 ~]# subscription-manager version
server type: Red Hat Subscription Management
subscription management server: 0.9.10-1
subscription-manager: 1.11.3-2.el5
python-rhsm: 1.11.3-2.el5


How reproducible:


Steps to Reproduce:
[root@jsefler-5 ~]# subscription-manager register --insecure --serverurl=jsefler-f14-candlepin.usersys.redhat.com:8443/candlepin
Username: testuser1
Password: 
Organization: admin
The system has been registered with ID: c8292d8f-ecb8-4568-99ba-c28cc951f298 
[root@jsefler-5 ~]# touch /tmp/foofile
[root@jsefler-5 ~]# rhsm-debug system --destination=/tmp/foofile
local variable 'dest_fo' referenced before assignment


Actual results:
above

Expected results:
[Errno 20] Not a directory: '/tmp/foofile/rhsm-debug-system-20140501-342280.tar.gz'
I claim this is expected result because this was the behavior on rhel7 and the error message is more descriptive of the problem than the traceback we are now seeing in rhel5.



Additional info:
[root@jsefler-5 ~]# tail -f /var/log/rhsm/rhsm.log
2014-05-01 10:44:22,262 [ERROR] rhsm-debug @managercli.py:156 - Unable to create zip file of system information: local variable 'dest_fo' referenced before assignment
2014-05-01 10:44:22,262 [ERROR] rhsm-debug @managercli.py:157 - local variable 'dest_fo' referenced before assignment
Traceback (most recent call last):
  File "/usr/share/rhsm/rhsm_debug/debug_commands.py", line 158, in _do_command
    sfm.move(tar_file_path, final_path)
  File "/usr/share/rhsm/rhsm_debug/debug_commands.py", line 261, in move
    dest_fo.close()
UnboundLocalError: local variable 'dest_fo' referenced before assignment

Comment 1 Carter Kozak 2014-05-01 15:08:36 UTC
commit dc23acfe0e863ad2cda5d57900621bfe0ba6a2a9
Author: ckozak <ckozak>
Date:   Thu May 1 11:05:47 2014 -0400

    1093382: fix file io problems created when replacing with() blocks

Comment 2 RHEL Program Management 2014-05-01 15:18:29 UTC
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.

Comment 4 Sharath Dwaral 2014-05-21 19:21:40 UTC
Version:

# subscription-manager version
server type: Red Hat Subscription Management
subscription management server: 0.9.12-1
subscription-manager: 1.11.3-3.el5
python-rhsm: 1.11.3-3.el5

Verification:

Steps followed as per comment1

# subscription-manager clean
All local data removed

# subscription-manager identity
This system is not yet registered. Try 'subscription-manager register --help' for more information.

# subscription-manager register --insecure --serverurl=f20-candlepin.usersys.redhat.com:8443/candlepin
Username: testuser1
Password: 
Organization: admin
The system has been registered with ID: de45398c-4c4d-40c1-957b-925ec8b32e18

# touch /tmp/foofile

# rhsm-debug system --destination=/tmp/foofile
[Errno 20] Not a directory: '/tmp/foofile/rhsm-debug-system-20140521-151745.tar.gz'            <<<<<<<<<<<<<<<<<


Additional Info:

2014-05-21 15:17:45,284 [DEBUG] rhsm-debug @connection.py:450 - Making request: GET /candlepin/status
2014-05-21 15:17:45,544 [DEBUG] rhsm-debug @connection.py:473 - Response: status=200, requestUuid=03719181-f82f-4276-b948-0b15b9fce5c0
2014-05-21 15:17:45,545 [INFO] rhsm-debug @managercli.py:304 - Server Versions: {'candlepin': '0.9.12-1', 'server-type': 'Red Hat Subscription Management'}
2014-05-21 15:17:45,545 [DEBUG] rhsm-debug @identity.py:130 - Loading consumer info from identity certificates.
2014-05-21 15:17:45,548 [DEBUG] rhsm-debug @connection.py:450 - Making request: GET /candlepin/consumers/de45398c-4c4d-40c1-957b-925ec8b32e18/owner
2014-05-21 15:17:45,854 [DEBUG] rhsm-debug @connection.py:473 - Response: status=200, requestUuid=dada671c-ba68-4e93-8e27-97d6325c994e
2014-05-21 15:17:45,856 [DEBUG] rhsm-debug @connection.py:450 - Making request: GET /candlepin/owners/admin/subscriptions
2014-05-21 15:17:46,538 [DEBUG] rhsm-debug @connection.py:473 - Response: status=200, requestUuid=f6e6453a-58e7-4f49-8187-a0b368e382fb
2014-05-21 15:17:46,857 [DEBUG] rhsm-debug @connection.py:450 - Making request: GET /candlepin/consumers/de45398c-4c4d-40c1-957b-925ec8b32e18
2014-05-21 15:17:47,215 [DEBUG] rhsm-debug @connection.py:473 - Response: status=200, requestUuid=fb47b16e-4768-4f6f-b820-de20c005ee30
2014-05-21 15:17:47,219 [DEBUG] rhsm-debug @connection.py:450 - Making request: GET /candlepin/consumers/de45398c-4c4d-40c1-957b-925ec8b32e18/compliance
2014-05-21 15:17:47,529 [DEBUG] rhsm-debug @connection.py:473 - Response: status=200, requestUuid=0ecd186e-a3f1-4e11-8f1c-de59c91ae635
2014-05-21 15:17:47,530 [DEBUG] rhsm-debug @connection.py:450 - Making request: GET /candlepin/consumers/de45398c-4c4d-40c1-957b-925ec8b32e18/entitlements?exclude=certificates.key&exclude=certificates.cert
2014-05-21 15:17:47,827 [DEBUG] rhsm-debug @connection.py:473 - Response: status=200, requestUuid=07c09e99-af1c-4daf-87ea-e789c089c91f
2014-05-21 15:17:47,829 [DEBUG] rhsm-debug @connection.py:450 - Making request: GET /candlepin/owners/admin/pools?consumer=de45398c-4c4d-40c1-957b-925ec8b32e18&listall=true
2014-05-21 15:17:50,013 [DEBUG] rhsm-debug @connection.py:473 - Response: status=200, requestUuid=4783c330-35df-4806-afb8-518202f1fdf2
2014-05-21 15:17:50,563 [ERROR] rhsm-debug @managercli.py:156 - Unable to create zip file of system information: [Errno 20] Not a directory: '/tmp/foofile/rhsm-debug-system-20140521-151745.tar.gz'
2014-05-21 15:17:50,563 [ERROR] rhsm-debug @managercli.py:157 - [Errno 20] Not a directory: '/tmp/foofile/rhsm-debug-system-20140521-151745.tar.gz'
Traceback (most recent call last):
  File "/usr/share/rhsm/rhsm_debug/debug_commands.py", line 158, in _do_command
    sfm.move(tar_file_path, final_path)
  File "/usr/share/rhsm/rhsm_debug/debug_commands.py", line 257, in move
    dest_fo = self._open_excl(dest)
  File "/usr/share/rhsm/rhsm_debug/debug_commands.py", line 270, in _open_excl
    self.default_perms), 'w+')
OSError: [Errno 20] Not a directory: '/tmp/foofile/rhsm-debug-system-20140521-151745.tar.gz'

Comment 7 errata-xmlrpc 2014-09-16 00:22:57 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.

http://rhn.redhat.com/errata/RHBA-2014-1225.html


Note You need to log in before you can comment on or make changes to this bug.