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 1630956 - skydive plugin traceback due to type conversion
Summary: skydive plugin traceback due to type conversion
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: sos
Version: 7.6
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: rc
: 7.7
Assignee: Pavel Moravec
QA Contact: Miroslav Hradílek
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2018-09-19 15:12 UTC by Miroslav Hradílek
Modified: 2019-08-06 13:15 UTC (History)
5 users (show)

Fixed In Version: sos-3.7-1.el7
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2019-08-06 13:15:20 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github sosreport sos pull 1526 0 None None None 2019-01-01 13:27:52 UTC
Red Hat Product Errata RHEA-2019:2295 0 None None None 2019-08-06 13:15:44 UTC

Description Miroslav Hradílek 2018-09-19 15:12:36 UTC
Description of problem:
In newly added skydive plugin in sos-3.6-9.el7.noarch there is a set of options that plugin uses to setupp environmental variables for analyzing tool.

Problem is that self.get_option does the implicit type conversion while os.environ expects only string.

Version-Release number of selected component (if applicable):
sos-3.6-9.el7.noarch

How reproducible:
100%

Steps to Reproduce:
sosreport -o skydive -k skydive.username=john -k skydive.password='123' -k skydive.analyzer=localhost --batch --debug

Actual results:
. . .
 Setting up archive ...
 Setting up plugins ...
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/sos/sosreport.py", line 1033, in setup
    plug.setup()
  File "/usr/lib/python2.7/site-packages/sos/plugins/skydive.py", line 55, in setup
    os.environ["SKYDIVE_PASSWORD"] = password
  File "/usr/lib64/python2.7/os.py", line 471, in __setitem__
    putenv(key, item)
TypeError: must be string, not int

> /usr/lib64/python2.7/os.py(471)__setitem__()
-> putenv(key, item)
(Pdb) 


Expected results:
Clean run.

Comment 2 Bryn M. Reeves 2018-09-19 15:27:25 UTC
I think this is probably something we can address in a subsequent errata: what's happening here is that the plugin options code is "helpfully" noticing that the string passed in is an integer, and is automatically casting it to a Python 'int' type.

That should only be the case if the "password" is a valid base-10 integer, which hopefully will not be a common case in the field.

There's a straightforward way to hack around this for this specific cases, although it would be better to carry out a review of the automatic type conversion and decide whether it's actually useful or not.

Comment 3 Miroslav Hradílek 2018-09-19 15:30:14 UTC
I agree, that is why I'm suggesting 7.7.

Comment 4 Bryn M. Reeves 2018-09-19 15:31:37 UTC
Works fine with either alpha/mixed strings:

# ./sosreport --batch --debug -o skydive -k skydive.username="qux",skydive.password="password"

sosreport (version 3.6)

This command will collect system configuration and diagnostic
information from this Fedora system. An archive containing the collected
information will be generated in /var/tmp/sos.ppM4se.

For more information on the Fedora Project visit:

  https://fedoraproject.org/

The generated archive may contain data considered sensitive and its
content should be reviewed by the originating organization before being
passed to any third party.

No changes will be made to system configuration.


 Setting up archive ...
 Setting up plugins ...
 Running plugins. Please wait ...

  Starting 1/1   skydive         [Running: skydive]

  Finished running plugins

Creating compressed archive...

Your sosreport has been generated and saved in:
  /var/tmp/sosreport-localhost-2018-09-19-eadnxwl.tar.xz

The checksum is: 7d9a19dfa7787aa59574760b07c9ce6a

Please send this file to your support representative.

And:

# ./sosreport --batch --debug -o skydive -k skydive.username="qux",skydive.password="1passw0rd"

sosreport (version 3.6)

[...]

  Starting 1/1   skydive         [Running: skydive]

  Finished running plugins

Creating compressed archive...

Your sosreport has been generated and saved in:
  /var/tmp/sosreport-localhost-2018-09-19-wrksnus.tar.xz

The checksum is: c72ed77b0def1bc2f89afbbd494aae3b

Please send this file to your support representative.

Comment 5 Pavel Moravec 2018-09-30 19:16:00 UTC
(In reply to Bryn M. Reeves from comment #2)
> I think this is probably something we can address in a subsequent errata:
> what's happening here is that the plugin options code is "helpfully"
> noticing that the string passed in is an integer, and is automatically
> casting it to a Python 'int' type.

We have several plugin options (logs.log_days and pcp.pcplogs at least) that relies on this automatic conversion. While several other plugins (skydive, postgresql at least) are affected by this BZ.

Anyway each opt_parms has its default value in "enabled" field - should not we ensure set_option preserves this type, "only"?

Comment 6 Pavel Moravec 2018-09-30 19:21:15 UTC
Dirty patch for this:

--- a/sos/plugins/__init__.py
+++ b/sos/plugins/__init__.py
@@ -499,6 +499,9 @@ class Plugin(object):
         '''set the named option to value.'''
         for name, parms in zip(self.opt_names, self.opt_parms):
             if name == optionname:
+		defaulttype = type(parms['enabled'])
+		if defaulttype != type(value):
+		    value = (defaulttype)(value)
                 parms['enabled'] = value
                 return True
         else:

Comment 7 Pavel Moravec 2019-03-20 10:38:31 UTC
POSTed to upstream.

Comment 11 errata-xmlrpc 2019-08-06 13:15:20 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/RHEA-2019:2295


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