Skip to content

Commit

Permalink
Check PID within the namespace
Browse files Browse the repository at this point in the history
PID filtering should only happen within current namespace
  • Loading branch information
grebennikov committed Oct 16, 2018
1 parent b399694 commit d14b5ac
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion unit_tests/test_zaza_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion zaza/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit d14b5ac

Please sign in to comment.