Skip to content

Commit b6df524

Browse files
authored
Add override_config to load_minigraph in config-setup service (#14834) (#15097)
This PR is to handle the override minigraph config by golden_config_db.json file if it is present in the backup location.
1 parent 5206fcd commit b6df524

File tree

4 files changed

+15
-3
lines changed

4 files changed

+15
-3
lines changed

files/Aboot/boot0.j2

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ clean_flash() {
118118
[ $f != "minigraph.xml" ] &&
119119
[ $f != "snmp.yml" ] &&
120120
[ $f != "acl.json" ] &&
121-
[ $f != "port_config.json" ]
121+
[ $f != "port_config.json" ] &&
122+
[ $f != "golden_config_db.json" ]
122123
then
123124
rm -rf "$target_path/$f"
124125
fi

files/image_config/config-setup/config-setup

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,11 @@ run_hookdir() {
109109
reload_minigraph()
110110
{
111111
echo "Reloading minigraph..."
112-
config load_minigraph -y -n
112+
if [ -f /etc/sonic/golden_config_db.json ]; then
113+
config load_minigraph -y -n --override_config --golden_config_path '/etc/sonic/golden_config_db.json'
114+
else
115+
config load_minigraph -y -n
116+
fi
113117
config save -y
114118
}
115119

@@ -305,7 +309,7 @@ check_all_config_db_present()
305309
do_config_migration()
306310
{
307311
# Identify list of files to migrate
308-
copy_list="minigraph.xml snmp.yml acl.json port_config.json frr telemetry"
312+
copy_list="minigraph.xml snmp.yml acl.json port_config.json frr telemetry golden_config_db.json"
309313

310314
# Migrate all configuration files from old to new
311315
copy_config_files_and_directories $copy_list

files/image_config/platform/rc.local

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ migrate_nos_configuration()
126126
PORT_CONFIG_GZFILE=$NOS_DIR/port_config.json.gz.base64.txt
127127
PORT_CONFIG_FILE=$NOS_DIR/port_config.json
128128
SNMP_FILE=$NOS_DIR/snmp.yml
129+
GOLDEN_CONFIG_DB_GZFILE=$NOS_DIR/golden_config_db.json.gz.base64.txt
130+
GOLDEN_CONFIG_DB_FILE=$NOS_DIR/golden_config_db.json
129131
mkdir -p $NOS_DIR
130132

131133
mount $nos_dev $NOS_DIR
@@ -137,13 +139,15 @@ migrate_nos_configuration()
137139
[ -f $MG_GZFILE ] && /usr/bin/base64 -d $MG_GZFILE | /bin/gunzip > $MG_FILE
138140
[ -f $ACL_GZFILE ] && /usr/bin/base64 -d $ACL_GZFILE | /bin/gunzip > $ACL_FILE
139141
[ -f $PORT_CONFIG_GZFILE ] && /usr/bin/base64 -d $PORT_CONFIG_GZFILE | /bin/gunzip > $PORT_CONFIG_FILE
142+
[ -f $GOLDEN_CONFIG_DB_GZFILE] && /usr/bin/base64 -d $GOLDEN_CONFIG_DB_GZFILE| /bin/gunzip > $GOLDEN_CONFIG_DB_FILE
140143

141144
# Copy relevant files
142145
nos_migration_import $NOS_DIR/mgmt_interface.cfg /host/migration
143146
nos_migration_import $MG_FILE /host/migration
144147
nos_migration_import $ACL_FILE /host/migration
145148
nos_migration_import $PORT_CONFIG_FILE /host/migration
146149
nos_migration_import $SNMP_FILE /host/migration
150+
nos_migration_import $GOLDEN_CONFIG_DB_FILE /host/migration
147151

148152
if [ "$sonic_fast_reboot" == true ]; then
149153
mkdir -p /host/fast-reboot
@@ -261,13 +265,15 @@ if [ -f $FIRST_BOOT_FILE ]; then
261265
[ -f /host/acl.json ] && mv /host/acl.json /etc/sonic/old_config/
262266
[ -f /host/port_config.json ] && mv /host/port_config.json /etc/sonic/old_config/
263267
[ -f /host/snmp.yml ] && mv /host/snmp.yml /etc/sonic/old_config/
268+
[ -f /host/golden_config_db.json ] && mv /host/golden_config_db.json /etc/sonic/old_config/
264269
touch /tmp/pending_config_migration
265270
elif [ -n "$migration" ] && [ -f /host/migration/minigraph.xml ]; then
266271
mkdir -p /etc/sonic/old_config
267272
mv /host/migration/minigraph.xml /etc/sonic/old_config/
268273
[ -f /host/migration/acl.json ] && mv /host/migration/acl.json /etc/sonic/old_config/
269274
[ -f /host/migration/port_config.json ] && mv /host/migration/port_config.json /etc/sonic/old_config/
270275
[ -f /host/migration/snmp.yml ] && mv /host/migration/snmp.yml /etc/sonic/old_config/
276+
[ -f /host/migration/golden_config_db.json ] && mv /host/migration/golden_config_db.json /etc/sonic/old_config/
271277
touch /tmp/pending_config_migration
272278
[ -f /etc/sonic/updategraph.conf ] && sed -i -e "s/enabled=false/enabled=true/g" /etc/sonic/updategraph.conf
273279
else

files/image_config/secureboot/allowlist_paths.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,4 @@ etc/subuid
3636
etc/tacplus_nss.conf
3737
etc/tacplus_user
3838
lib/systemd/system/[email protected]
39+
etc/sonic/golden_config_db.json

0 commit comments

Comments
 (0)