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 @@ -257,10 +257,18 @@ function postStartAction()
257
257
$SONIC_DB_CLI CONFIG_DB SET " CONFIG_DB_INITIALIZED" " 1"
258
258
fi
259
259
260
- if [[ -x /usr/local/bin/db_migrator.py ]]; then
261
- # Migrate the DB to the latest schema version if needed
262
- if [ -z " $DEV " ]; then
263
- /usr/local/bin/db_migrator.py -o migrate
260
+ if [ -e /tmp/pending_config_migration ]; then
261
+ # this is first boot to a new image, config-setup execution is pending.
262
+ # For fast/cold reboot case, DB contains nothing at this point
263
+ # Call db_migrator after config-setup loads the config (from old config or minigraph)
264
+ echo " Delaying db_migrator until config migration is over"
265
+ else
266
+ # this is not a first time boot to a new image. Datbase container starts w/ old pre-existing config
267
+ if [[ -x /usr/local/bin/db_migrator.py ]]; then
268
+ # Migrate the DB to the latest schema version if needed
269
+ if [ -z " $DEV " ]; then
270
+ /usr/local/bin/db_migrator.py -o migrate
271
+ fi
264
272
fi
265
273
fi
266
274
# 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 @@ -304,6 +304,16 @@ check_all_config_db_present()
304
304
return 0
305
305
}
306
306
307
+ # DB schema is subject to change between two images
308
+ # Perform DB schema migration after loading backup config from previous image
309
+ do_db_migration ()
310
+ {
311
+ if [[ -x /usr/local/bin/db_migrator.py ]]; then
312
+ # Migrate the DB to the latest schema version if needed
313
+ /usr/local/bin/db_migrator.py -o migrate
314
+ fi
315
+ }
316
+
307
317
# Perform configuration migration from backup copy.
308
318
# - This step is performed when a new image is installed and SONiC switch boots into it
309
319
do_config_migration ()
@@ -326,16 +336,19 @@ do_config_migration()
326
336
if [ x" ${WARM_BOOT} " == x" true" ]; then
327
337
echo " Warm reboot detected..."
328
338
disable_updategraph
339
+ do_db_migration
329
340
rm -f /tmp/pending_config_migration
330
341
exit 0
331
342
elif check_all_config_db_present; then
332
343
echo " Use config_db.json from old system..."
333
344
reload_configdb
345
+ do_db_migration
334
346
# Disable updategraph
335
347
disable_updategraph
336
348
elif [ -r ${MINGRAPH_FILE} ]; then
337
349
echo " Use minigraph.xml from old system..."
338
350
reload_minigraph
351
+ do_db_migration
339
352
# Disable updategraph
340
353
disable_updategraph
341
354
else
You can’t perform that action at this time.
0 commit comments