From d14b5ac1e3cb63572637ac66bf499300feee6933 Mon Sep 17 00:00:00 2001 From: Andrey Grebennikov Date: Thu, 11 Oct 2018 15:49:32 -0500 Subject: [PATCH] Check PID within the namespace PID filtering should only happen within current namespace --- unit_tests/test_zaza_model.py | 2 +- zaza/model.py | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/unit_tests/test_zaza_model.py b/unit_tests/test_zaza_model.py index fe567b957..d3fb3e0d9 100644 --- a/unit_tests/test_zaza_model.py +++ b/unit_tests/test_zaza_model.py @@ -708,7 +708,7 @@ async def _run_on_unit( self.async_run_on_unit.side_effect = _run_on_unit self.assertEqual( model.get_unit_service_start_time('app/2', 'mysvc1'), 1524409654) - cmd = "stat -c %Y /proc/$(pidof -x mysvc1 | cut -f1 -d ' ')" + cmd = "stat -c %Y /proc/$(pgrep mysvc1 --nslist pid --ns 1 | head -n1)" self.async_run_on_unit.assert_called_once_with( unit_name='app/2', command=cmd, diff --git a/zaza/model.py b/zaza/model.py index 181b214b0..e1d108d09 100644 --- a/zaza/model.py +++ b/zaza/model.py @@ -323,7 +323,8 @@ async def async_get_unit_service_start_time(unit_name, service, :rtype: int :raises: ServiceNotRunning """ - cmd = "stat -c %Y /proc/$(pidof -x {} | cut -f1 -d ' ')".format(service) + cmd = ("stat -c %Y /proc/$(pgrep {} --nslist pid" + " --ns 1 | head -n1)").format(service) out = await async_run_on_unit( unit_name=unit_name, command=cmd,