RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1432303 - targetcli ls command will fail with 'TERM' not defined in os.enviorn
Summary: targetcli ls command will fail with 'TERM' not defined in os.enviorn
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: python-configshell
Version: 7.4
Hardware: All
OS: Linux
medium
urgent
Target Milestone: rc
: ---
Assignee: Andy Grover
QA Contact: Martin Hoyer
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-03-15 03:32 UTC by Wayne Sun
Modified: 2021-09-03 13:45 UTC (History)
10 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2017-08-01 20:54:35 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2017:2031 0 normal SHIPPED_LIVE targetcli, python-configshell, python-rtslib bug fix and enhancement update 2017-08-01 18:34:25 UTC

Description Wayne Sun 2017-03-15 03:32:19 UTC
Description of problem:
targetcli ls command will fail with 'TERM' not defined in os.enviorn

2017-03-14 02:33:52,112 process          L0333 INFO | Running 'targetcli ls /iscsi 1'
2017-03-14 02:33:52,162 process          L0420 DEBUG| [stderr] Traceback (most recent call last):
2017-03-14 02:33:52,162 process          L0420 DEBUG| [stderr]   File "/usr/bin/targetcli", line 24, in <module>
2017-03-14 02:33:52,163 process          L0420 DEBUG| [stderr]     from targetcli import UIRoot
2017-03-14 02:33:52,163 process          L0420 DEBUG| [stderr]   File "/usr/lib/python2.7/site-packages/targetcli/__init__.py", line 18, in <module>
2017-03-14 02:33:52,163 process          L0420 DEBUG| [stderr]     from .ui_root import UIRoot
2017-03-14 02:33:52,163 process          L0420 DEBUG| [stderr]   File "/usr/lib/python2.7/site-packages/targetcli/ui_root.py", line 26, in <module>
2017-03-14 02:33:52,163 process          L0420 DEBUG| [stderr]     from configshell_fb import ExecutionError
2017-03-14 02:33:52,163 process          L0420 DEBUG| [stderr]   File "/usr/lib/python2.7/site-packages/configshell_fb/__init__.py", line 27, in <module>
2017-03-14 02:33:52,163 process          L0420 DEBUG| [stderr]     from .shell import ConfigShell
2017-03-14 02:33:52,164 process          L0420 DEBUG| [stderr]   File "/usr/lib/python2.7/site-packages/configshell_fb/shell.py", line 53, in <module>
2017-03-14 02:33:52,164 process          L0420 DEBUG| [stderr]     oldTerm = os.environ['TERM']
2017-03-14 02:33:52,164 process          L0420 DEBUG| [stderr]   File "/usr/lib64/python2.7/UserDict.py", line 23, in __getitem__
2017-03-14 02:33:52,164 process          L0420 DEBUG| [stderr]     raise KeyError(key)
2017-03-14 02:33:52,164 process          L0420 DEBUG| [stderr] KeyError: 'TERM'

Version-Release number of selected component (if applicable):
# rpm -q targetcli python-configshell kernel
targetcli-2.1.fb46-1.el7.noarch
python-configshell-1.1.fb23-1.el7.noarch
kernel-3.10.0-603.el7.ppc64le


How reproducible:
always in jenkins shell job or when 'TERM' is not in env

Steps to Reproduce:
1.
# python
Python 2.7.5 (default, Mar 13 2017, 12:06:50) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os, subprocess
>>> print (os.environ['TERM'])
xterm-256color
>>> del os.environ['TERM']
>>> print (os.environ['TERM'])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python2.7/UserDict.py", line 23, in __getitem__
    raise KeyError(key)
KeyError: 'TERM'
>>> subprocess.Popen("targetcli ls /iscsi 1", shell=True, stdout=subprocess.PIPE).stdout.read()
Traceback (most recent call last):
  File "/usr/bin/targetcli", line 24, in <module>
    from targetcli import UIRoot
  File "/usr/lib/python2.7/site-packages/targetcli/__init__.py", line 18, in <module>
    from .ui_root import UIRoot
  File "/usr/lib/python2.7/site-packages/targetcli/ui_root.py", line 26, in <module>
    from configshell_fb import ExecutionError
  File "/usr/lib/python2.7/site-packages/configshell_fb/__init__.py", line 27, in <module>
    from .shell import ConfigShell
  File "/usr/lib/python2.7/site-packages/configshell_fb/shell.py", line 53, in <module>
    oldTerm = os.environ['TERM']
  File "/usr/lib64/python2.7/UserDict.py", line 23, in __getitem__
    raise KeyError(key)
KeyError: 'TERM'
''
>>> 

2.
3.

Actual results:
Fail

Expected results:
Success

Additional info:
This is bring in by commit:
https://github.com/open-iscsi/configshell-fb/commit/82f79eb2f967ecd820d531488d0b64d6015b1aaf

which did not check whether TERM is in env

Comment 3 Jess Calciano 2017-05-12 20:20:06 UTC
I've also recently run into this - any updates on a fix or an official workaround?

It's definitely a problem in Jenkins, like the original description states. To manually reproduce the problem:
1. Run targetcli from a remote host:
   # ssh user@host 'targetcli ls'

2. The Python KeyError and traceback above appears.

Comment 4 michal novacek 2017-05-18 08:37:48 UTC
This breaks HA resource-agents (iSCSITarget and iSCSILogicalUnit) which are using targetcli.

This needs to be fixed in 7.4 timeframe.

Comment 8 Martin Hoyer 2017-06-09 13:53:30 UTC
Reproducible with python-configshell-1.1.fb23-1.el7
Working well with python-configshell-1.1.fb23-2.el7
Regression tests did not found any new issue.

Comment 9 errata-xmlrpc 2017-08-01 20:54:35 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-2017:2031


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