Skip to content

Commit

Permalink
Fix GCU bug when backend service modifying config (#2295)
Browse files Browse the repository at this point in the history
What I did
Fixes sonic-net/sonic-buildimage#11576

How I did it
Add a workaround to only compare config without backend service impact.

How to verify it
Manual test on specific platform and check operation success.
  • Loading branch information
wen587 authored Aug 9, 2022
1 parent bcf36eb commit be1866f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
12 changes: 12 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()
self.remove_backend_tables_from_config(upd_data)
self.remove_backend_tables_from_config(run_data)
if upd_data != run_data:
self._report_mismatch(run_data, upd_data)
ret = -1
Expand All @@ -150,6 +157,11 @@ def apply(self, change):
return ret


def remove_backend_tables_from_config(self, data):
for key in self.backend_tables:
data.pop(key, None)


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()
self.changeapplier.remove_backend_tables_from_config(target_config)
self.changeapplier.remove_backend_tables_from_config(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 be1866f

Please sign in to comment.