From 94a8d5715a033c65ec86969ffaeebd7e96818cb5 Mon Sep 17 00:00:00 2001 From: Santhosh Fernandes Date: Wed, 28 Jun 2017 10:39:42 +0530 Subject: [PATCH] Option to enable provisioning status sync with neutron db In large build situations, nova can be slow to build VMs, this means that the default 100 second timeout may expire before the final status has been updated in the neutron database. This patch will emit provisioning status to be sync with neutron db Change-Id: If6c0b81630fd1911518792d9947f8622f065ff4e --- etc/octavia.conf | 3 +++ octavia/common/config.py | 4 +++- octavia/common/constants.py | 1 + octavia/controller/healthmanager/update_db.py | 14 +++++++++++--- ...visioning_neutron_db_sync-c019d96a7b64fe20.yaml | 8 ++++++++ 5 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 releasenotes/notes/provisioning_neutron_db_sync-c019d96a7b64fe20.yaml diff --git a/etc/octavia.conf b/etc/octavia.conf index f3c3f17a27..362d7ac568 100644 --- a/etc/octavia.conf +++ b/etc/octavia.conf @@ -72,6 +72,9 @@ # noop_event_streamer # event_streamer_driver = noop_event_streamer +# Enable provisioning status sync with neutron db +# sync_provisioning_status = False + [keystone_authtoken] # This group of config options are imported from keystone middleware. Thus the # option names should match the names declared in the middleware. diff --git a/octavia/common/config.py b/octavia/common/config.py index 63c33eac2f..7a0918f452 100644 --- a/octavia/common/config.py +++ b/octavia/common/config.py @@ -183,7 +183,9 @@ healthmanager_opts = [ 'don\'t need to sync the database or are running ' 'octavia in stand alone mode use the ' 'noop_event_streamer'), - default='noop_event_streamer')] + default='noop_event_streamer'), + cfg.BoolOpt('sync_provisioning_status', default=False, + help=_("Enable provisioning status sync with neutron db"))] oslo_messaging_opts = [ cfg.StrOpt('topic'), diff --git a/octavia/common/constants.py b/octavia/common/constants.py index 4250903db9..909992de2f 100644 --- a/octavia/common/constants.py +++ b/octavia/common/constants.py @@ -107,6 +107,7 @@ DEGRADED = 'DEGRADED' ERROR = 'ERROR' NO_MONITOR = 'NO_MONITOR' OPERATING_STATUS = 'operating_status' +PROVISIONING_STATUS = 'provisioning_status' SUPPORTED_OPERATING_STATUSES = (ONLINE, OFFLINE, DEGRADED, ERROR, NO_MONITOR) AMPHORA_VM = 'VM' diff --git a/octavia/controller/healthmanager/update_db.py b/octavia/controller/healthmanager/update_db.py index 4d2b1e7987..14381256e6 100644 --- a/octavia/controller/healthmanager/update_db.py +++ b/octavia/controller/healthmanager/update_db.py @@ -42,6 +42,7 @@ class UpdateHealthDb(object): self.loadbalancer_repo = repo.LoadBalancerRepository() self.member_repo = repo.MemberRepository() self.pool_repo = repo.PoolRepository() + self.sync_prv_status = cfg.CONF.health_manager.sync_provisioning_status def emit(self, info_type, info_id, info_obj): cnt = update_serializer.InfoContainer(info_type, info_id, info_obj) @@ -50,15 +51,22 @@ class UpdateHealthDb(object): def _update_status_and_emit_event(self, session, repo, entity_type, entity_id, new_op_status): entity = repo.get(session, id=entity_id) + message = {} if entity.operating_status.lower() != new_op_status.lower(): LOG.debug("%s %s status has changed from %s to " "%s. Updating db and sending event.", entity_type, entity_id, entity.operating_status, new_op_status) repo.update(session, entity_id, operating_status=new_op_status) - self.emit( - entity_type, entity_id, - {constants.OPERATING_STATUS: new_op_status}) + message.update({constants.OPERATING_STATUS: new_op_status}) + if self.sync_prv_status: + LOG.debug("%s %s provisioning_status %s. Updating db and sending" + " event.", entity_type, entity_id, + entity.provisioning_status) + message.update( + {constants.PROVISIONING_STATUS: entity.provisioning_status}) + if message: + self.emit(entity_type, entity_id, message) def update_health(self, health): """This function is to update db info based on amphora status diff --git a/releasenotes/notes/provisioning_neutron_db_sync-c019d96a7b64fe20.yaml b/releasenotes/notes/provisioning_neutron_db_sync-c019d96a7b64fe20.yaml new file mode 100644 index 0000000000..d2bc404d62 --- /dev/null +++ b/releasenotes/notes/provisioning_neutron_db_sync-c019d96a7b64fe20.yaml @@ -0,0 +1,8 @@ +--- +upgrade: + - Added option 'sync_provisioning_status' to enable synchronizing provisioning status + of loadbalancers with the neutron-lbaas database. Enabling this option will queue one + additional message per amphora every heartbeat interval. +fixes: + - Resolved an issue that could cause provisioning status to become out of sync between + neutron-lbaas and octavia during high load.