Prevent sync states from bouncing when a subcloud is managed

When a subcloud is first set to managed, the dcorch endpoint
sync status keeps toggling between the two states - "in-sync"
and "out-of-sync", before settling on "in-sync". This is
because during the audit run, different endpoints (sysinv and
identity) are done in separate greenthreads and each
greenthread processes the resources (e.g. users, projects)
in series. Thus, an enhancement is made to reduce the
unnecessary messaging between dcorch and dcmanager, and to
avoid the bouncing sync states.

Change-Id: I98cec42eb5880d95d54182339dab6b5c951d6cfd
Story: 2007267
Task: 38996
Signed-off-by: Jessica Castelino <jessica.castelino@windriver.com>
This commit is contained in:
Jessica Castelino 2020-03-27 15:20:12 -04:00
parent 085a685d54
commit b0636c1ed8
1 changed files with 14 additions and 0 deletions

View File

@ -91,6 +91,7 @@ class SyncThread(object):
self.admin_session = None
self.ks_client = None
self.dbs_client = None
self.initial_audit_in_progress = False
def start(self):
if self.status == STATUS_NEW:
@ -206,6 +207,7 @@ class SyncThread(object):
def enable(self):
# Called when DC manager thinks this subcloud is good to go.
self.initialize()
self.initial_audit_in_progress = True
self.wake()
self.run_sync_audit()
@ -281,6 +283,11 @@ class SyncThread(object):
self.sync_status = sync_status
self.subcloud_managed = subcloud_managed
# If initial audit is in progress, do not send the endpoint
# status update to dcmanager
if self.initial_audit_in_progress:
return
self.dcmanager_rpc_client.update_subcloud_endpoint_status(
self.ctxt, self.subcloud_engine.subcloud.region_name,
self.endpoint_type, sync_status)
@ -496,6 +503,13 @@ class SyncThread(object):
extra=self.log_extra)
self.post_audit()
# Once initial audit is complete, we wake up the sync thread
# so that it sends a proper sync status update (either in-sync or
# out-of-sync) to dcmanager for that endpoint type.
if self.initial_audit_in_progress:
self.initial_audit_in_progress = False
self.wake()
@lockutils.synchronized(AUDIT_LOCK_NAME)
def post_audit(self):
# reset the cached master resources