From b0636c1ed89d062bf777b22ad05512d655c13401 Mon Sep 17 00:00:00 2001 From: Jessica Castelino Date: Fri, 27 Mar 2020 15:20:12 -0400 Subject: [PATCH] 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 --- distributedcloud/dcorch/engine/sync_thread.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/distributedcloud/dcorch/engine/sync_thread.py b/distributedcloud/dcorch/engine/sync_thread.py index 58127f679..76d624794 100644 --- a/distributedcloud/dcorch/engine/sync_thread.py +++ b/distributedcloud/dcorch/engine/sync_thread.py @@ -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