Revert "Revert "Fix for fast/cold-boot: call db_migrator only after old config is loaded (#14933)" (#15464)" (#15684) (#16223)
This commit is contained in:
parent
32a52a13df
commit
5d5727f6b9
@ -135,10 +135,18 @@ function postStartAction()
|
|||||||
$SONIC_DB_CLI CONFIG_DB SET "CONFIG_DB_INITIALIZED" "1"
|
$SONIC_DB_CLI CONFIG_DB SET "CONFIG_DB_INITIALIZED" "1"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -x /usr/local/bin/db_migrator.py ]]; then
|
if [ -e /tmp/pending_config_migration ]; then
|
||||||
# Migrate the DB to the latest schema version if needed
|
# this is first boot to a new image, config-setup execution is pending.
|
||||||
if [ -z "$DEV" ]; then
|
# For fast/cold reboot case, DB contains nothing at this point
|
||||||
/usr/local/bin/db_migrator.py -o migrate
|
# Call db_migrator after config-setup loads the config (from old config or minigraph)
|
||||||
|
echo "Delaying db_migrator until config migration is over"
|
||||||
|
else
|
||||||
|
# this is not a first time boot to a new image. Datbase container starts w/ old pre-existing config
|
||||||
|
if [[ -x /usr/local/bin/db_migrator.py ]]; then
|
||||||
|
# Migrate the DB to the latest schema version if needed
|
||||||
|
if [ -z "$DEV" ]; then
|
||||||
|
/usr/local/bin/db_migrator.py -o migrate
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
# Add redis UDS to the redis group and give read/write access to the group
|
# Add redis UDS to the redis group and give read/write access to the group
|
||||||
|
@ -298,6 +298,16 @@ check_all_config_db_present()
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# DB schema is subject to change between two images
|
||||||
|
# Perform DB schema migration after loading backup config from previous image
|
||||||
|
do_db_migration()
|
||||||
|
{
|
||||||
|
if [[ -x /usr/local/bin/db_migrator.py ]]; then
|
||||||
|
# Migrate the DB to the latest schema version if needed
|
||||||
|
/usr/local/bin/db_migrator.py -o migrate
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Perform configuration migration from backup copy.
|
# Perform configuration migration from backup copy.
|
||||||
# - This step is performed when a new image is installed and SONiC switch boots into it
|
# - This step is performed when a new image is installed and SONiC switch boots into it
|
||||||
do_config_migration()
|
do_config_migration()
|
||||||
@ -320,16 +330,19 @@ do_config_migration()
|
|||||||
if [ x"${WARM_BOOT}" == x"true" ]; then
|
if [ x"${WARM_BOOT}" == x"true" ]; then
|
||||||
echo "Warm reboot detected..."
|
echo "Warm reboot detected..."
|
||||||
disable_updategraph
|
disable_updategraph
|
||||||
|
do_db_migration
|
||||||
rm -f /tmp/pending_config_migration
|
rm -f /tmp/pending_config_migration
|
||||||
exit 0
|
exit 0
|
||||||
elif check_all_config_db_present; then
|
elif check_all_config_db_present; then
|
||||||
echo "Use config_db.json from old system..."
|
echo "Use config_db.json from old system..."
|
||||||
reload_configdb
|
reload_configdb
|
||||||
|
do_db_migration
|
||||||
# Disable updategraph
|
# Disable updategraph
|
||||||
disable_updategraph
|
disable_updategraph
|
||||||
elif [ -r ${MINGRAPH_FILE} ]; then
|
elif [ -r ${MINGRAPH_FILE} ]; then
|
||||||
echo "Use minigraph.xml from old system..."
|
echo "Use minigraph.xml from old system..."
|
||||||
reload_minigraph
|
reload_minigraph
|
||||||
|
do_db_migration
|
||||||
# Disable updategraph
|
# Disable updategraph
|
||||||
disable_updategraph
|
disable_updategraph
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user