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 1035795 - tuna throwing valueerror when not specified priority
Summary: tuna throwing valueerror when not specified priority
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: tuna
Version: 6.4
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: rc
: ---
Assignee: John Kacur
QA Contact: Jiri Kastner
URL:
Whiteboard:
Depends On: 1035793 1035796
Blocks: 1023565
TreeView+ depends on / blocked
 
Reported: 2013-11-28 13:46 UTC by Jiri Kastner
Modified: 2014-10-14 04:26 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of: 1035793
Environment:
Last Closed: 2014-10-14 04:26:21 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
Fix (973 bytes, patch)
2013-12-02 08:52 UTC, Petr Oros
no flags Details | Diff


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2014:1404 0 normal SHIPPED_LIVE tuna bug fix update 2014-10-14 00:55:00 UTC

Description Jiri Kastner 2013-11-28 13:46:05 UTC
+++ This bug was initially created as a clone of Bug #1035793 +++

Description of problem:
when after scheduler is not specified priority 'tuna -t $PID -p OTHER' (it doesn't matter if RR or FIFO or OTHER), tuna ends with traceback.

Version-Release number of selected component (if applicable):
every

How reproducible:
alway

Steps to Reproduce:
1. install tuna
2. run tuna -t PID_OF_SOME_PROCESS -p OTHER
3. check output

Actual results:

[root@localhost ~]# tuna -t 3199 -p OTHER
Traceback (most recent call last):
  File "/usr/bin/tuna", line 598, in <module>
    main()
  File "/usr/bin/tuna", line 482, in main
    tuna.threads_set_priority(thread_list, a, affect_children)
  File "/usr/lib/python2.6/site-packages/tuna/tuna.py", line 479, in threads_set_priority
    rtprio = int(parms[0])
ValueError: invalid literal for int() with base 10: 'OTHER'


Expected results:
instead of traceback some warning and/or used some default value.

Additional info:

Comment 2 Petr Oros 2013-12-02 08:52:09 UTC
Created attachment 831472 [details]
Fix

Comment 3 John Kacur 2014-03-28 00:38:44 UTC
Fixed in 0.10.4-5

Comment 9 Clark Williams 2014-07-29 18:42:28 UTC
What do you guys think about this patch? Is this what we want for parameter verification?


diff --git a/tuna/tuna.py b/tuna/tuna.py
index 507269a..6fdeb9e 100755
--- a/tuna/tuna.py
+++ b/tuna/tuna.py
@@ -471,15 +471,18 @@ def move_threads_to_cpu(cpus, pid_list, set_affinity_warning = None,
 
 def threads_set_priority(tids, parm, affect_children = False):
        parms = parm.split(":")
+        rtprio = -1
        policy = None
-       if len(parms) != 1:
+        if parms[0].upper() in ["OTHER", "BATCH", "IDLE", "FIFO", "RR", "IDLE", "RESET_ON_FORK"]:
                policy = schedutils.schedfromstr("SCHED_%s" % parms[0].upper())
-               rtprio = int(parms[1])
-       elif parms[0].isdigit():
-               rtprio = int(parms[0])
-       else:
-               print "tuna: " + _("\"%s\" is unsupported priority value!") % parms[0]
-               return
+        if len(parms) > 1:
+                if parms[1].isdigit():
+                        rtprio = int(parms[1])
+                else:
+                        print "tuna: " + _("\"%s\" is unsupported priority value!") % parms[1]
+                        return
+        else:
+                rtprio = 0
 
        for tid in tids:
                try:

Comment 10 Clark Williams 2014-07-29 21:20:51 UTC
Here's an updated patch that uses a try/except (to be a bit more python-ish):

diff --git a/tuna/tuna.py b/tuna/tuna.py
index 507269a..7e71348 100755
--- a/tuna/tuna.py
+++ b/tuna/tuna.py
@@ -471,15 +471,16 @@ def move_threads_to_cpu(cpus, pid_list, set_affinity_warning = None,
 
 def threads_set_priority(tids, parm, affect_children = False):
        parms = parm.split(":")
+        rtprio = 0
        policy = None
-       if len(parms) != 1:
-               policy = schedutils.schedfromstr("SCHED_%s" % parms[0].upper())
-               rtprio = int(parms[1])
-       elif parms[0].isdigit():
-               rtprio = int(parms[0])
-       else:
-               print "tuna: " + _("\"%s\" is unsupported priority value!") % parms[0]
-               return
+        if parms[0].upper() in ["OTHER", "BATCH", "IDLE", "FIFO", "RR", "IDLE", "RESET_ON_FORK"]:
+                policy = schedutils.schedfromstr("SCHED_%s" % parms[0].upper())
+        if len(parms) > 1:
+                try:
+                        rtprio = int(parms[1])
+                except ValueError, e:
+                        print "tuna: " + _("\"%s\" is unsupported priority value!") % parms[1]
+                        raise e
 
        for tid in tids:
                try:

Comment 16 John Kacur 2014-08-25 22:56:40 UTC
In addition to the fix here which I provided in tuna-0.10.4-7
we need to upgrade procfs to python-linux-procfs-0.4.6-1

Then you get the following result which I believe is acceptable

tuna -t $$ -p FIFO
tuna: [Errno 22] Invalid argument

I created https://bugzilla.redhat.com/show_bug.cgi?id=1035795
to handle this

Comment 20 errata-xmlrpc 2014-10-14 04:26:21 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-1404.html


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