From: Ondrej Lichtner <olichtne(a)redhat.com>
If the job is already finished there's no need to attempt the rpc call
to send a signal. Instead, the method logs this information and returns
True immediately.
The patch also includes updates to where the kill method was used while
doing this check explicitly by removing the check.
Signed-off-by: Ondrej Lichtner <olichtne(a)redhat.com>
---
lnst/Controller/Job.py | 5 +++++
lnst/RecipeCommon/Perf/Measurements/IperfFlowMeasurement.py | 6 ++----
lnst/RecipeCommon/Perf/Measurements/StatCPUMeasurement.py | 3 +--
lnst/RecipeCommon/Perf/Measurements/TRexFlowMeasurement.py | 6 ++----
lnst/Recipes/ENRT/OvS_DPDK_PvP.py | 2 +-
5 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/lnst/Controller/Job.py b/lnst/Controller/Job.py
index d3786be..92ea483 100644
--- a/lnst/Controller/Job.py
+++ b/lnst/Controller/Job.py
@@ -190,6 +190,11 @@ class Job(object):
signal was sent successfully.
False if an exception was raised while sending the signal.
"""
+ if self.finished:
+ logging.info("Job {} on host {} already finished, skipping kill
call."
+ .format(self._id, self._netns.hostid))
+ return True
+
logging.info("Sending signal {} to job {} on host {}".format(signal,
self._id, self._netns.hostid))
return self._netns._machine.kill(self, signal)
diff --git a/lnst/RecipeCommon/Perf/Measurements/IperfFlowMeasurement.py
b/lnst/RecipeCommon/Perf/Measurements/IperfFlowMeasurement.py
index 5267ae2..2f8ae98 100644
--- a/lnst/RecipeCommon/Perf/Measurements/IperfFlowMeasurement.py
+++ b/lnst/RecipeCommon/Perf/Measurements/IperfFlowMeasurement.py
@@ -44,10 +44,8 @@ class IperfFlowMeasurement(BaseFlowMeasurement):
flow.server_job.wait(timeout=5)
finally:
for flow in test_flows:
- if not flow.server_job.finished:
- flow.server_job.kill()
- if not flow.client_job.finished:
- flow.client_job.kill()
+ flow.server_job.kill()
+ flow.client_job.kill()
self._running_measurements = []
self._finished_measurements = test_flows
diff --git a/lnst/RecipeCommon/Perf/Measurements/StatCPUMeasurement.py
b/lnst/RecipeCommon/Perf/Measurements/StatCPUMeasurement.py
index 14e7f73..5aa316f 100644
--- a/lnst/RecipeCommon/Perf/Measurements/StatCPUMeasurement.py
+++ b/lnst/RecipeCommon/Perf/Measurements/StatCPUMeasurement.py
@@ -45,8 +45,7 @@ class StatCPUMeasurement(BaseCPUMeasurement):
job.wait()
finally:
for job in jobs:
- if not job.finished:
- job.kill()
+ job.kill()
self._running_measurements = []
self._finished_measurements = jobs
diff --git a/lnst/RecipeCommon/Perf/Measurements/TRexFlowMeasurement.py
b/lnst/RecipeCommon/Perf/Measurements/TRexFlowMeasurement.py
index d1ca75f..f47ec67 100644
--- a/lnst/RecipeCommon/Perf/Measurements/TRexFlowMeasurement.py
+++ b/lnst/RecipeCommon/Perf/Measurements/TRexFlowMeasurement.py
@@ -46,10 +46,8 @@ class TRexFlowMeasurement(BaseFlowMeasurement):
test.server_job.wait(5)
finally:
for test in tests:
- if not test.server_job.finished:
- test.server_job.kill()
- if not test.client_job.finished:
- test.client_job.kill()
+ test.server_job.kill()
+ test.client_job.kill()
self._running_measurements = []
self._finished_measurements = tests
diff --git a/lnst/Recipes/ENRT/OvS_DPDK_PvP.py b/lnst/Recipes/ENRT/OvS_DPDK_PvP.py
index aa8af24..0004c79 100644
--- a/lnst/Recipes/ENRT/OvS_DPDK_PvP.py
+++ b/lnst/Recipes/ENRT/OvS_DPDK_PvP.py
@@ -400,7 +400,7 @@ class OvSDPDKPvPRecipe(PingTestAndEvaluate, PerfRecipe):
return
testpmd = guest_conf.testpmd
- if testpmd and not testpmd.finished:
+ if testpmd:
testpmd.kill(signal.SIGINT)
testpmd.wait()
--
2.19.1