Handle "no such process" during keepalived process cleanup
First, the _stop_keepalived_manager() was doing redundant work of the KeepalivedManager.disable() method. I.e. SIGTERM pid wait for 5s and then SIGKILL. Therefore I removed that code from the test file. Next, I wrapped the self.manager.disable() to handle for the non atomic operation of the disable() function where SIGTERM can sometimes stop the process right before the SIGKILL is called. We dont want this to fail the test as shown in the linked bug. Closes-Bug: #2017037 Change-Id: Ide244c079094f60779ce446283e5d51ae15e9af3
This commit is contained in:
@@ -13,7 +13,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import signal
|
||||
|
||||
from oslo_config import cfg
|
||||
|
||||
@@ -27,6 +26,7 @@ from neutron.tests.common import net_helpers
|
||||
from neutron.tests.functional.agent.linux import helpers
|
||||
from neutron.tests.functional import base
|
||||
from neutron.tests.unit.agent.linux import test_keepalived
|
||||
from neutron_lib.exceptions import ProcessExecutionError
|
||||
|
||||
|
||||
class KeepalivedManagerTestCase(base.BaseSudoTestCase,
|
||||
@@ -51,12 +51,17 @@ class KeepalivedManagerTestCase(base.BaseSudoTestCase,
|
||||
self.addCleanup(self._stop_keepalived_manager)
|
||||
|
||||
def _stop_keepalived_manager(self):
|
||||
self.manager.disable()
|
||||
try:
|
||||
common_utils.wait_until_true(
|
||||
lambda: not self.manager.get_process().active, timeout=5)
|
||||
except common_utils.WaitTimeout:
|
||||
self.manager.get_process().disable(sig=signal.SIGKILL)
|
||||
self.manager.disable()
|
||||
except ProcessExecutionError as process_err:
|
||||
# self.manager.disable() will perform SIGTERM->wait->SIGKILL
|
||||
# (if needed) on the process. However, it is sometimes possible
|
||||
# that SIGKILL gets called on a process that just exited due to
|
||||
# SIGTERM. Ignore this condition so the test is not marked as
|
||||
# failed.
|
||||
if not (len(process_err.args) > 0 and
|
||||
"No such process" in process_err.args[0]):
|
||||
raise
|
||||
|
||||
def _prepare_devices(self):
|
||||
# NOTE(slaweq): those are devices used in keepalived config file,
|
||||
|
Reference in New Issue
Block a user