File tree 2 files changed +25
-4
lines changed
image_config/config-setup
2 files changed +25
-4
lines changed Original file line number Diff line number Diff line change @@ -135,10 +135,18 @@ function postStartAction()
135
135
$SONIC_DB_CLI CONFIG_DB SET " CONFIG_DB_INITIALIZED" " 1"
136
136
fi
137
137
138
- if [[ -x /usr/local/bin/db_migrator.py ]]; then
139
- # Migrate the DB to the latest schema version if needed
140
- if [ -z " $DEV " ]; then
141
- /usr/local/bin/db_migrator.py -o migrate
138
+ if [ -e /tmp/pending_config_migration ]; then
139
+ # this is first boot to a new image, config-setup execution is pending.
140
+ # For fast/cold reboot case, DB contains nothing at this point
141
+ # Call db_migrator after config-setup loads the config (from old config or minigraph)
142
+ echo " Delaying db_migrator until config migration is over"
143
+ else
144
+ # this is not a first time boot to a new image. Datbase container starts w/ old pre-existing config
145
+ if [[ -x /usr/local/bin/db_migrator.py ]]; then
146
+ # Migrate the DB to the latest schema version if needed
147
+ if [ -z " $DEV " ]; then
148
+ /usr/local/bin/db_migrator.py -o migrate
149
+ fi
142
150
fi
143
151
fi
144
152
# Add redis UDS to the redis group and give read/write access to the group
Original file line number Diff line number Diff line change @@ -298,6 +298,16 @@ check_all_config_db_present()
298
298
return 0
299
299
}
300
300
301
+ # DB schema is subject to change between two images
302
+ # Perform DB schema migration after loading backup config from previous image
303
+ do_db_migration ()
304
+ {
305
+ if [[ -x /usr/local/bin/db_migrator.py ]]; then
306
+ # Migrate the DB to the latest schema version if needed
307
+ /usr/local/bin/db_migrator.py -o migrate
308
+ fi
309
+ }
310
+
301
311
# Perform configuration migration from backup copy.
302
312
# - This step is performed when a new image is installed and SONiC switch boots into it
303
313
do_config_migration ()
@@ -320,16 +330,19 @@ do_config_migration()
320
330
if [ x" ${WARM_BOOT} " == x" true" ]; then
321
331
echo " Warm reboot detected..."
322
332
disable_updategraph
333
+ do_db_migration
323
334
rm -f /tmp/pending_config_migration
324
335
exit 0
325
336
elif check_all_config_db_present; then
326
337
echo " Use config_db.json from old system..."
327
338
reload_configdb
339
+ do_db_migration
328
340
# Disable updategraph
329
341
disable_updategraph
330
342
elif [ -r ${MINGRAPH_FILE} ]; then
331
343
echo " Use minigraph.xml from old system..."
332
344
reload_minigraph
345
+ do_db_migration
333
346
# Disable updategraph
334
347
disable_updategraph
335
348
else
You can’t perform that action at this time.
0 commit comments