From 7128d732bc3de88d903740f3feae8f4ef4362cfe Mon Sep 17 00:00:00 2001 From: huangshan Date: Tue, 26 Jun 2018 14:55:41 +0800 Subject: [PATCH] Add exception handling for housekeeping service Capture exceptions for each thread's task handler to prevent it from exiting abnormaly. Story: 2001749 Task: 12128 Change-Id: I0fef53347e4460b8e6e200589736ae65c85a5145 --- octavia/cmd/house_keeping.py | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/octavia/cmd/house_keeping.py b/octavia/cmd/house_keeping.py index 47f046e204..588180a8f1 100644 --- a/octavia/cmd/house_keeping.py +++ b/octavia/cmd/house_keeping.py @@ -44,7 +44,11 @@ def spare_amphora_check(): spare_amp = house_keeping.SpareAmphora() while not spare_amp_thread_event.is_set(): LOG.debug("Initiating spare amphora check...") - spare_amp.spare_check() + try: + spare_amp.spare_check() + except Exception as e: + LOG.debug('spare_amphora caught the following exception and ' + 'is restarting: {}'.format(e)) spare_amp_thread_event.wait(interval) @@ -61,8 +65,12 @@ def db_cleanup(): db_cleanup = house_keeping.DatabaseCleanup() while not db_cleanup_thread_event.is_set(): LOG.debug("Initiating the cleanup of old resources...") - db_cleanup.delete_old_amphorae() - db_cleanup.cleanup_load_balancers() + try: + db_cleanup.delete_old_amphorae() + db_cleanup.cleanup_load_balancers() + except Exception as e: + LOG.debug('db_cleanup caught the following exception and ' + 'is restarting: {}'.format(e)) db_cleanup_thread_event.wait(interval) @@ -74,7 +82,11 @@ def cert_rotation(): cert_rotate = house_keeping.CertRotation() while not cert_rotate_thread_event.is_set(): LOG.debug("Initiating certification rotation ...") - cert_rotate.rotate() + try: + cert_rotate.rotate() + except Exception as e: + LOG.debug('cert_rotation caught the following exception and ' + 'is restarting: {}'.format(e)) cert_rotate_thread_event.wait(interval)