Skip to content

Commit 4dce058

Browse files
committed
Fix GCU bug when backend service modifying config
1 parent ecb9136 commit 4dce058

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

generic_config_updater/change_applier.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ class ChangeApplier:
7171

7272
def __init__(self):
7373
self.config_db = get_config_db()
74+
self.backend_tables = [
75+
"BUFFER_PG",
76+
"BUFFER_PROFILE",
77+
"FLEX_COUNTER_TABLE"
78+
]
7479
if (not ChangeApplier.updater_conf) and os.path.exists(UPDATER_CONF_FILE):
7580
with open(UPDATER_CONF_FILE, "r") as s:
7681
ChangeApplier.updater_conf = json.load(s)
@@ -142,6 +147,8 @@ def apply(self, change):
142147
ret = self._services_validate(run_data, upd_data, upd_keys)
143148
if not ret:
144149
run_data = self._get_running_config()
150+
upd_data = self.get_config_without_backend_tables(upd_data)
151+
run_data = self.get_config_without_backend_tables(run_data)
145152
if upd_data != run_data:
146153
self._report_mismatch(run_data, upd_data)
147154
ret = -1
@@ -150,6 +157,13 @@ def apply(self, change):
150157
return ret
151158

152159

160+
def get_config_without_backend_tables(self, data):
161+
cropped_data = {
162+
k: v for k, v in data.items() if k not in self.backend_tables
163+
}
164+
return cropped_data
165+
166+
153167
def _get_running_config(self):
154168
(_, fname) = tempfile.mkstemp(suffix="_changeApplier")
155169
os.system("sonic-cfggen -d --print-data > {}".format(fname))

generic_config_updater/generic_updater.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ def apply(self, patch):
7777
# Validate config updated successfully
7878
self.logger.log_notice("Verifying patch updates are reflected on ConfigDB.")
7979
new_config = self.config_wrapper.get_config_db_as_json()
80+
target_config = self.changeapplier.get_config_without_backend_tables(target_config)
81+
new_config = self.changeapplier.get_config_without_backend_tables(new_config)
8082
if not(self.patch_wrapper.verify_same_json(target_config, new_config)):
8183
raise GenericConfigUpdaterError(f"After applying patch to config, there are still some parts not updated")
8284

0 commit comments

Comments
 (0)