From bfaf0ebc116cc5e3d5ae0fe5cd41bcc6fde58717 Mon Sep 17 00:00:00 2001 From: Slawek Kaplonski Date: Fri, 9 Apr 2021 15:28:41 +0200 Subject: [PATCH] Always use absolute path for custom kill-scripts When rootwrap was used to run custom kill-scripts, it worked fine with the executable name without full path as path was in the rootwrap's exec_dirs config option thus rootwrap was able to find it. But as we migrated to privsep it don't works like that anymore. It's better to use absolute path of the kill-script always and that patch changes to do it like that. Change-Id: I66d70304530935e2add3345aba6aa3c549a0a2df Closes-Bug: #1923198 (cherry picked from commit e5ccfee6cfb503c3ba7cce816fae331dd017f3ce) --- neutron/agent/linux/external_process.py | 5 +++-- neutron/tests/unit/agent/linux/test_external_process.py | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/neutron/agent/linux/external_process.py b/neutron/agent/linux/external_process.py index e8437336ae8..5a82f3fdc2d 100644 --- a/neutron/agent/linux/external_process.py +++ b/neutron/agent/linux/external_process.py @@ -128,8 +128,9 @@ class ProcessManager(MonitoredProcess): def get_kill_cmd(self, sig, pid): if self.kill_scripts_path: kill_file = "%s-kill" % self.service - if os.path.isfile(os.path.join(self.kill_scripts_path, kill_file)): - return [kill_file, sig, pid] + kill_file_path = os.path.join(self.kill_scripts_path, kill_file) + if os.path.isfile(kill_file_path): + return [kill_file_path, sig, pid] return ['kill', '-%s' % (sig), pid] def get_pid_file_name(self): diff --git a/neutron/tests/unit/agent/linux/test_external_process.py b/neutron/tests/unit/agent/linux/test_external_process.py index d2aa240098a..3821a30b7b7 100644 --- a/neutron/tests/unit/agent/linux/test_external_process.py +++ b/neutron/tests/unit/agent/linux/test_external_process.py @@ -271,7 +271,8 @@ class TestProcessManager(base.BaseTestCase): kill_scripts_path='test-path/'): cfg.CONF.set_override("kill_scripts_path", kill_scripts_path, "AGENT") if kill_script_exists: - expected_cmd = ['test-service-kill', '9', 4] + expected_cmd = [ + os.path.join(kill_scripts_path, 'test-service-kill'), '9', 4] else: expected_cmd = ['kill', '-9', 4]