Improve Apache PID check on service restart
In case there are containers with Apache running on the same host, the charm will only watch PIDs within the same namespace. Change-Id: I9cdd7d5b1f53fce748e7fafab538676e4e55dd54 Closes-Bug: #1795918
This commit is contained in:
parent
59561fdda0
commit
f0ee669279
|
@ -512,7 +512,8 @@ def restart_pid_check(service_name, ptable_string=None):
|
|||
@retry_on_exception(5, base_delay=3, exc_type=AssertionError)
|
||||
def check_pids_gone(svc_string):
|
||||
log("Checking no pids for {} exist".format(svc_string), level=INFO)
|
||||
assert(subprocess.call(["pgrep", svc_string]) == 1)
|
||||
assert(subprocess.call(["pgrep", svc_string, "--nslist", "pid",
|
||||
"--ns", str(os.getpid())]) == 1)
|
||||
|
||||
if not ptable_string:
|
||||
ptable_string = service_name
|
||||
|
|
|
@ -822,14 +822,18 @@ class TestKeystoneUtils(CharmTestCase):
|
|||
utils.restart_pid_check('apache2')
|
||||
self.service_stop.assert_called_once_with('apache2')
|
||||
self.service_start.assert_called_once_with('apache2')
|
||||
self.subprocess.call.assert_called_once_with(['pgrep', 'apache2'])
|
||||
self.subprocess.call.assert_called_once_with(
|
||||
['pgrep', 'apache2', '--nslist', 'pid', '--ns', str(os.getpid())]
|
||||
)
|
||||
|
||||
def test_restart_pid_check_ptable_string(self):
|
||||
self.subprocess.call.return_value = 1
|
||||
utils.restart_pid_check('apache2', ptable_string='httpd')
|
||||
self.service_stop.assert_called_once_with('apache2')
|
||||
self.service_start.assert_called_once_with('apache2')
|
||||
self.subprocess.call.assert_called_once_with(['pgrep', 'httpd'])
|
||||
self.subprocess.call.assert_called_once_with(
|
||||
['pgrep', 'httpd', '--nslist', 'pid', '--ns', str(os.getpid())]
|
||||
)
|
||||
|
||||
# Do not sleep() to speed up manual runs.
|
||||
@patch('charmhelpers.core.decorators.time')
|
||||
|
@ -841,9 +845,12 @@ class TestKeystoneUtils(CharmTestCase):
|
|||
self.service_start.assert_called_once_with('apache2')
|
||||
# self.subprocess.call.assert_called_once_with(['pgrep', 'httpd'])
|
||||
expected = [
|
||||
call(['pgrep', 'httpd']),
|
||||
call(['pgrep', 'httpd']),
|
||||
call(['pgrep', 'httpd']),
|
||||
call(['pgrep', 'httpd', '--nslist', 'pid', '--ns',
|
||||
str(os.getpid())]),
|
||||
call(['pgrep', 'httpd', '--nslist', 'pid', '--ns',
|
||||
str(os.getpid())]),
|
||||
call(['pgrep', 'httpd', '--nslist', 'pid', '--ns',
|
||||
str(os.getpid())])
|
||||
]
|
||||
self.assertEqual(self.subprocess.call.call_args_list, expected)
|
||||
|
||||
|
|
Loading…
Reference in New Issue