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 f808bf2c21..a97ea5bdea 100644 --- a/octavia/controller/worker/v2/controller_worker.py +++ b/octavia/controller/worker/v2/controller_worker.py @@ -134,6 +134,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', + db_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 7488b01477..d5200e3aa9 100644 --- a/octavia/controller/worker/v2/tasks/database_tasks.py +++ b/octavia/controller/worker/v2/tasks/database_tasks.py @@ -1856,7 +1856,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],