Skip to content

Commit 65c65e1

Browse files
committed
Handle same image warm-reboot and generalize handling of INIT flag
1 parent e0d3f0a commit 65c65e1

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

files/build_templates/docker_image_ctl.j2

+6-3
Original file line numberDiff line numberDiff line change
@@ -256,15 +256,16 @@ function postStartAction()
256256
# set the key to expire in 3 minutes
257257
$SONIC_DB_CLI STATE_DB SET "FAST_REBOOT|system" "1" "EX" "180"
258258
fi
259-
260-
$SONIC_DB_CLI CONFIG_DB SET "CONFIG_DB_INITIALIZED" "1"
261259
fi
262260

263261
if [ -e /tmp/pending_config_migration ]; then
264262
# this is first boot to a new image, config-setup execution is pending.
263+
# for warmboot case, DB is loaded but migration is still pending
265264
# For fast/cold reboot case, DB contains nothing at this point
266-
# Call db_migrator after config-setup loads the config (from old config or minigraph)
265+
# Call db_migrator and set CONFIG_DB_INITIALIZED after config-setup loads the config (from old config or minigraph)
267266
echo "Delaying db_migrator until config migration is over"
267+
# unset CONFIG_DB_INITIALIZED to indicate pending config load and migration
268+
$SONIC_DB_CLI CONFIG_DB SET "CONFIG_DB_INITIALIZED" "0"
268269
else
269270
# this is not a first time boot to a new image. Datbase container starts w/ old pre-existing config
270271
if [[ -x /usr/local/bin/db_migrator.py ]]; then
@@ -273,6 +274,8 @@ function postStartAction()
273274
/usr/local/bin/db_migrator.py -o migrate
274275
fi
275276
fi
277+
# set CONFIG_DB_INITIALIZED to indicate end of config load and migration
278+
$SONIC_DB_CLI CONFIG_DB SET "CONFIG_DB_INITIALIZED" "1"
276279
fi
277280
# Add redis UDS to the redis group and give read/write access to the group
278281
REDIS_SOCK="/var/run/redis${DEV}/redis.sock"

files/image_config/config-setup/config-setup

+2-2
Original file line numberDiff line numberDiff line change
@@ -305,13 +305,14 @@ check_all_config_db_present()
305305
}
306306

307307
# DB schema is subject to change between two images
308-
# Perform DB schema migration after loading backup config from previous image
308+
# Perform DB schema migration after loading backup config/minigraph from previous image
309309
do_db_migration()
310310
{
311311
if [[ -x /usr/local/bin/db_migrator.py ]]; then
312312
# Migrate the DB to the latest schema version if needed
313313
/usr/local/bin/db_migrator.py -o migrate
314314
fi
315+
sonic-db-cli CONFIG_DB SET "CONFIG_DB_INITIALIZED" "1"
315316
}
316317

317318
# Perform configuration migration from backup copy.
@@ -338,7 +339,6 @@ do_config_migration()
338339
disable_updategraph
339340
do_db_migration
340341
rm -f /tmp/pending_config_migration
341-
sonic-db-cli CONFIG_DB SET "CONFIG_DB_INITIALIZED" "1"
342342
exit 0
343343
elif check_all_config_db_present; then
344344
echo "Use config_db.json from old system..."

0 commit comments

Comments
 (0)