Skip to content

Commit d14b5ac

Browse files
committed
Check PID within the namespace
PID filtering should only happen within current namespace
1 parent b399694 commit d14b5ac

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

unit_tests/test_zaza_model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,7 @@ async def _run_on_unit(
708708
self.async_run_on_unit.side_effect = _run_on_unit
709709
self.assertEqual(
710710
model.get_unit_service_start_time('app/2', 'mysvc1'), 1524409654)
711-
cmd = "stat -c %Y /proc/$(pidof -x mysvc1 | cut -f1 -d ' ')"
711+
cmd = "stat -c %Y /proc/$(pgrep mysvc1 --nslist pid --ns 1 | head -n1)"
712712
self.async_run_on_unit.assert_called_once_with(
713713
unit_name='app/2',
714714
command=cmd,

zaza/model.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,8 @@ async def async_get_unit_service_start_time(unit_name, service,
323323
:rtype: int
324324
:raises: ServiceNotRunning
325325
"""
326-
cmd = "stat -c %Y /proc/$(pidof -x {} | cut -f1 -d ' ')".format(service)
326+
cmd = ("stat -c %Y /proc/$(pgrep {} --nslist pid"
327+
" --ns 1 | head -n1)").format(service)
327328
out = await async_run_on_unit(
328329
unit_name=unit_name,
329330
command=cmd,

0 commit comments

Comments
 (0)