Bug 1278757

Summary: [RFE] - handle SIGTERM in rteval as end of run
Product: Red Hat Enterprise Linux 7 Reporter: Jiri Kastner <jkastner>
Component: rtevalAssignee: Luis Claudio R. Goncalves <lgoncalv>
Status: CLOSED ERRATA QA Contact: Jiri Kastner <jkastner>
Severity: unspecified Docs Contact: Maxim Svistunov <msvistun>
Priority: unspecified    
Version: 7.3CC: bhu, jkacur, jkastner, kzhang, msvistun, williams
Target Milestone: rcKeywords: FutureFeature
Target Release: 7.3   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Enhancement
Doc Text:
The rteval program program now treats both SIGINT and SIGTERM as stop events and preserves all the data that has been gathered up to the event.
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-11-04 01:34:06 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:
Embargoed:
Bug Depends On:    
Bug Blocks: 1274397, 1282922, 1313485    

Description Jiri Kastner 2015-11-06 11:07:21 UTC
Description of problem:
when ctrl+c is pressed, rteval return traceback and all gathered data are lost. currently 

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


How reproducible:


Steps to Reproduce:
1.
2.
3.

Actual results:
[root@mrg-qe-14 ~]# date
Fri Nov  6 11:41:16 CET 2015
[root@mrg-qe-14 ~]# rteval -d 20m
rteval run on 3.10.0-327.rt56.204.el7.x86_64 started at Fri Nov  6 11:41:29 2015
started 2 loads on 6 cores
Run duration: 1200.0 seconds
^C[root@mrg-qe-14 ~]# 


Expected results:
when ctrl+c is pressed, or rteval receive sigkill or sigterm signal, we should see results

Additional info:

Comment 3 Clark Williams 2016-03-29 17:42:30 UTC
This proposed patch changes run behavior to treat both SIGINT and SIGTERM as stop events. Is this what you're looking for?

diff --git a/rteval/__init__.py b/rteval/__init__.py
index 8ff8429277de..15209da2e7b2 100644
--- a/rteval/__init__.py
+++ b/rteval/__init__.py
@@ -24,7 +24,7 @@
 #
 
 """
-Copyright (c) 2008-2013  Red Hat Inc.
+Copyright (c) 2008-2016  Red Hat Inc.
 
 Realtime verification utility
 """
@@ -44,17 +44,15 @@ import version
 
 RTEVAL_VERSION = version.RTEVAL_VERSION
 
-sigint_received = False
+stopsig_received = False
 def sig_handler(signum, frame):
 
-    if signum == signal.SIGINT:
-        global sigint_received
-        sigint_received = True
-        print "*** SIGINT received - stopping rteval run ***"
-    elif signum == signal.SIGTERM:
-        raise RuntimeError("SIGTERM received!")
-
-
+    if signum == signal.SIGINT or signum == signal.SIGTERM:
+        global stopsig_received
+        stopsig_received = True
+        print "*** stop signal received - stopping rteval run ***"
+    else:
+        raise RuntimeError("SIGNAL received! (%d)" % signum)
 
 class RtEval(rtevalReport):
     def __init__(self, config, loadmods, measuremods, logger):
@@ -209,7 +207,7 @@ sigint_received = False
             currtime = time.time()
             rpttime = currtime + report_interval
             load_avg_checked = 5
-            while (currtime <= stoptime) and not sigint_received:
+            while (currtime <= stoptime) and not stopsig_received:
                 time.sleep(60.0)
                 if not measure_profile.isAlive():
                     stoptime = currtime

Comment 8 errata-xmlrpc 2016-11-04 01:34:06 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://rhn.redhat.com/errata/RHBA-2016-2244.html