Revert "AsyncProcess: try to kill tender"
This change introduced bug 1495937.
This reverts commit 470a7d8a10
.
Change-Id: I84fea4fdac71141da335ccd9e0d4c9d6174dfd86
This commit is contained in:
@@ -30,7 +30,7 @@ find: RegExpFilter, find, root, find, /sys/class/net, -maxdepth, 1, -type, l, -p
|
|||||||
ip_exec: IpNetnsExecFilter, ip, root
|
ip_exec: IpNetnsExecFilter, ip, root
|
||||||
|
|
||||||
# For ip monitor
|
# For ip monitor
|
||||||
kill_ip_monitor: KillFilter, root, ip, -9, -15
|
kill_ip_monitor: KillFilter, root, ip, -9
|
||||||
|
|
||||||
# ovs_lib (if OVSInterfaceDriver is used)
|
# ovs_lib (if OVSInterfaceDriver is used)
|
||||||
ovs-vsctl: CommandFilter, ovs-vsctl, root
|
ovs-vsctl: CommandFilter, ovs-vsctl, root
|
||||||
|
@@ -14,7 +14,7 @@
|
|||||||
ovs-vsctl: CommandFilter, ovs-vsctl, root
|
ovs-vsctl: CommandFilter, ovs-vsctl, root
|
||||||
# NOTE(yamamoto): of_interface=native doesn't use ovs-ofctl
|
# NOTE(yamamoto): of_interface=native doesn't use ovs-ofctl
|
||||||
ovs-ofctl: CommandFilter, ovs-ofctl, root
|
ovs-ofctl: CommandFilter, ovs-ofctl, root
|
||||||
kill_ovsdb_client: KillFilter, root, /usr/bin/ovsdb-client, -9, -15
|
kill_ovsdb_client: KillFilter, root, /usr/bin/ovsdb-client, -9
|
||||||
ovsdb-client: CommandFilter, ovsdb-client, root
|
ovsdb-client: CommandFilter, ovsdb-client, root
|
||||||
xe: CommandFilter, xe, root
|
xe: CommandFilter, xe, root
|
||||||
|
|
||||||
|
@@ -161,26 +161,20 @@ class AsyncProcess(object):
|
|||||||
self._kill_event = None
|
self._kill_event = None
|
||||||
|
|
||||||
def _kill_process(self, pid):
|
def _kill_process(self, pid):
|
||||||
for sig, timeout in [('-15', 5), ('-9', -1)]:
|
try:
|
||||||
try:
|
# A process started by a root helper will be running as
|
||||||
# A process started by a root helper will be running as
|
# root and need to be killed via the same helper.
|
||||||
# root and need to be killed via the same helper.
|
utils.execute(['kill', '-9', pid], run_as_root=self.run_as_root)
|
||||||
utils.execute(['kill', sig, pid], run_as_root=self.run_as_root)
|
except Exception as ex:
|
||||||
except Exception as ex:
|
stale_pid = (isinstance(ex, RuntimeError) and
|
||||||
stale_pid = (isinstance(ex, RuntimeError) and
|
'No such process' in str(ex))
|
||||||
'No such process' in str(ex))
|
if not stale_pid:
|
||||||
if not stale_pid:
|
LOG.exception(_LE('An error occurred while killing [%s].'),
|
||||||
LOG.exception(_LE('An error occurred while killing [%s].'),
|
self.cmd)
|
||||||
self.cmd)
|
return False
|
||||||
return False
|
|
||||||
return True
|
|
||||||
|
|
||||||
if self._process:
|
if self._process:
|
||||||
while timeout != 0:
|
self._process.wait()
|
||||||
if self._process.poll() is not None:
|
|
||||||
return True
|
|
||||||
eventlet.sleep(1)
|
|
||||||
timeout -= 1
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def _handle_process_error(self):
|
def _handle_process_error(self):
|
||||||
|
@@ -54,7 +54,7 @@ class TestAsyncProcess(AsyncProcessTestFramework):
|
|||||||
|
|
||||||
# Ensure that the process and greenthreads have stopped
|
# Ensure that the process and greenthreads have stopped
|
||||||
proc._process.wait()
|
proc._process.wait()
|
||||||
self.assertEqual(proc._process.returncode, -15)
|
self.assertEqual(proc._process.returncode, -9)
|
||||||
for watcher in proc._watchers:
|
for watcher in proc._watchers:
|
||||||
watcher.wait()
|
watcher.wait()
|
||||||
|
|
||||||
|
@@ -192,9 +192,8 @@ class TestAsyncProcess(base.BaseTestCase):
|
|||||||
actual = self.proc._kill_process(pid)
|
actual = self.proc._kill_process(pid)
|
||||||
|
|
||||||
self.assertEqual(expected, actual)
|
self.assertEqual(expected, actual)
|
||||||
mock_execute.assert_has_calls(
|
mock_execute.assert_called_with(['kill', '-9', pid],
|
||||||
[mock.call(['kill', '-15', pid],
|
run_as_root=self.proc.run_as_root)
|
||||||
run_as_root=self.proc.run_as_root)])
|
|
||||||
|
|
||||||
def test__kill_process_returns_true_for_valid_pid(self):
|
def test__kill_process_returns_true_for_valid_pid(self):
|
||||||
self._test__kill_process('1', True)
|
self._test__kill_process('1', True)
|
||||||
@@ -205,29 +204,6 @@ class TestAsyncProcess(base.BaseTestCase):
|
|||||||
def test__kill_process_returns_false_for_execute_exception(self):
|
def test__kill_process_returns_false_for_execute_exception(self):
|
||||||
self._test__kill_process('1', False, 'Invalid')
|
self._test__kill_process('1', False, 'Invalid')
|
||||||
|
|
||||||
def test__kill_process_with_9(self):
|
|
||||||
class Mockpoll(object):
|
|
||||||
# This must be larger than timeout (5)
|
|
||||||
i = 6
|
|
||||||
|
|
||||||
def __call__(self):
|
|
||||||
self.i -= 1
|
|
||||||
return None if self.i >= 0 else 0
|
|
||||||
|
|
||||||
self.proc.run_as_root = True
|
|
||||||
pid = '1'
|
|
||||||
with mock.patch.object(utils, 'execute') as mock_execute,\
|
|
||||||
mock.patch.object(self.proc, '_process') as mock_process,\
|
|
||||||
mock.patch.object(mock_process, 'poll', new=Mockpoll()):
|
|
||||||
actual = self.proc._kill_process(pid)
|
|
||||||
|
|
||||||
self.assertTrue(actual)
|
|
||||||
self.assertEqual([mock.call(['kill', '-15', pid],
|
|
||||||
run_as_root=self.proc.run_as_root),
|
|
||||||
mock.call(['kill', '-9', pid],
|
|
||||||
run_as_root=self.proc.run_as_root)],
|
|
||||||
mock_execute.mock_calls)
|
|
||||||
|
|
||||||
def test_stop_calls_kill(self):
|
def test_stop_calls_kill(self):
|
||||||
self.proc._kill_event = True
|
self.proc._kill_event = True
|
||||||
with mock.patch.object(self.proc, '_kill') as mock_kill:
|
with mock.patch.object(self.proc, '_kill') as mock_kill:
|
||||||
|
Reference in New Issue
Block a user