diff --git a/octavia/controller/queue/v2/endpoints.py b/octavia/controller/queue/v2/endpoints.py index 008cd2a44d..5bdba41f4a 100644 --- a/octavia/controller/queue/v2/endpoints.py +++ b/octavia/controller/queue/v2/endpoints.py @@ -95,19 +95,19 @@ class Endpoints(object): def create_health_monitor(self, context, health_monitor): LOG.info('Creating health monitor \'%s\'...', health_monitor.get( - constants.ID)) + constants.HEALTHMONITOR_ID)) self.worker.create_health_monitor(health_monitor) def update_health_monitor(self, context, original_health_monitor, health_monitor_updates): LOG.info('Updating health monitor \'%s\'...', - original_health_monitor.get(constants.ID)) + original_health_monitor.get(constants.HEALTHMONITOR_ID)) self.worker.update_health_monitor(original_health_monitor, health_monitor_updates) def delete_health_monitor(self, context, health_monitor): LOG.info('Deleting health monitor \'%s\'...', health_monitor.get( - constants.ID)) + constants.HEALTHMONITOR_ID)) self.worker.delete_health_monitor(health_monitor) def create_member(self, context, member): diff --git a/octavia/controller/worker/v2/controller_worker.py b/octavia/controller/worker/v2/controller_worker.py index 996e70e197..4736170b63 100644 --- a/octavia/controller/worker/v2/controller_worker.py +++ b/octavia/controller/worker/v2/controller_worker.py @@ -139,6 +139,12 @@ class ControllerWorker(object): db_apis.get_session(), id=health_monitor[constants.HEALTHMONITOR_ID]) + if not db_health_monitor: + LOG.warning('Failed to fetch %s %s from DB. Retrying for up to ' + '60 seconds.', 'healthmonitor', + health_monitor[constants.HEALTHMONITOR_ID]) + raise db_exceptions.NoResultFound + pool = db_health_monitor.pool pool.health_monitor = db_health_monitor load_balancer = pool.load_balancer diff --git a/octavia/controller/worker/v2/tasks/database_tasks.py b/octavia/controller/worker/v2/tasks/database_tasks.py index 02c24c7830..6dd3576f2b 100644 --- a/octavia/controller/worker/v2/tasks/database_tasks.py +++ b/octavia/controller/worker/v2/tasks/database_tasks.py @@ -1874,7 +1874,9 @@ class MarkHealthMonitorActiveInDB(BaseDatabaseTask): LOG.debug("Mark ACTIVE in DB for health monitor id: %s", health_mon[constants.HEALTHMONITOR_ID]) - op_status = (constants.ONLINE if health_mon[constants.ADMIN_STATE_UP] + db_health_mon = self.health_mon_repo.get( + db_apis.get_session(), id=health_mon[constants.HEALTHMONITOR_ID]) + op_status = (constants.ONLINE if db_health_mon.enabled else constants.OFFLINE) self.health_mon_repo.update(db_apis.get_session(), health_mon[constants.HEALTHMONITOR_ID],