Skip to content

Commit

Permalink
Fix GCU bug when backend service modifying config
Browse files Browse the repository at this point in the history
  • Loading branch information
wen587 committed Aug 4, 2022
1 parent ecb9136 commit 4dce058
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
14 changes: 14 additions & 0 deletions generic_config_updater/change_applier.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ class ChangeApplier:

def __init__(self):
self.config_db = get_config_db()
self.backend_tables = [
"BUFFER_PG",
"BUFFER_PROFILE",
"FLEX_COUNTER_TABLE"
]
if (not ChangeApplier.updater_conf) and os.path.exists(UPDATER_CONF_FILE):
with open(UPDATER_CONF_FILE, "r") as s:
ChangeApplier.updater_conf = json.load(s)
Expand Down Expand Up @@ -142,6 +147,8 @@ def apply(self, change):
ret = self._services_validate(run_data, upd_data, upd_keys)
if not ret:
run_data = self._get_running_config()
upd_data = self.get_config_without_backend_tables(upd_data)
run_data = self.get_config_without_backend_tables(run_data)
if upd_data != run_data:
self._report_mismatch(run_data, upd_data)
ret = -1
Expand All @@ -150,6 +157,13 @@ def apply(self, change):
return ret


def get_config_without_backend_tables(self, data):
cropped_data = {
k: v for k, v in data.items() if k not in self.backend_tables
}
return cropped_data


def _get_running_config(self):
(_, fname) = tempfile.mkstemp(suffix="_changeApplier")
os.system("sonic-cfggen -d --print-data > {}".format(fname))
Expand Down
2 changes: 2 additions & 0 deletions generic_config_updater/generic_updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ def apply(self, patch):
# Validate config updated successfully
self.logger.log_notice("Verifying patch updates are reflected on ConfigDB.")
new_config = self.config_wrapper.get_config_db_as_json()
target_config = self.changeapplier.get_config_without_backend_tables(target_config)
new_config = self.changeapplier.get_config_without_backend_tables(new_config)
if not(self.patch_wrapper.verify_same_json(target_config, new_config)):
raise GenericConfigUpdaterError(f"After applying patch to config, there are still some parts not updated")

Expand Down

0 comments on commit 4dce058

Please sign in to comment.