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