| Summary: | tuna throwing valueerror when not specified priority | ||||||
|---|---|---|---|---|---|---|---|
| Product: | Red Hat Enterprise Linux 6 | Reporter: | Jiri Kastner <jkastner> | ||||
| Component: | tuna | Assignee: | John Kacur <jkacur> | ||||
| Status: | CLOSED ERRATA | QA Contact: | Jiri Kastner <jkastner> | ||||
| Severity: | medium | Docs Contact: | |||||
| Priority: | medium | ||||||
| Version: | 6.4 | CC: | bhu, jkastner, lgoncalv, poros, williams | ||||
| Target Milestone: | rc | ||||||
| Target Release: | --- | ||||||
| Hardware: | Unspecified | ||||||
| OS: | Unspecified | ||||||
| Whiteboard: | |||||||
| Fixed In Version: | Doc Type: | Bug Fix | |||||
| Doc Text: | Story Points: | --- | |||||
| Clone Of: | 1035793 | Environment: | |||||
| Last Closed: | 2014-10-14 04:26:21 UTC | Type: | Bug | ||||
| Regression: | --- | Mount Type: | --- | ||||
| Documentation: | --- | CRM: | |||||
| Verified Versions: | Category: | --- | |||||
| oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |||||
| Cloudforms Team: | --- | Target Upstream Version: | |||||
| Bug Depends On: | 1035793, 1035796 | ||||||
| Bug Blocks: | 1023565 | ||||||
| Attachments: |
|
||||||
|
Description
Jiri Kastner
2013-11-28 13:46:05 UTC
Created attachment 831472 [details]
Fix
Fixed in 0.10.4-5 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:
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:
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 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 |