Skip to content

Commit 18049ef

Browse files
vivekrnvmssonicbld
authored andcommitted
Run db_migrator for non first-time reboots (sonic-net#16116)
- Why I did it The recent change sonic-net#15685 (comment) removed the db migration for non first reboots. This is problematic for many deployments which doesn't rely on ZTP and push a custom config_db.json Port to older branches after sonic-net#15685 is ported back - How I did it Re-introduce the logic to run the db_migrator on non-first boots - How to verify it Verified reboot and warm-reboot cases Signed-off-by: Vivek Reddy Karri <[email protected]>
1 parent f0b03b7 commit 18049ef

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

files/build_templates/docker_image_ctl.j2

+9
Original file line numberDiff line numberDiff line change
@@ -259,9 +259,18 @@ function postStartAction()
259259
# This flag will be set to "1" after DB migration/initialization is completed as part of config-setup
260260
$SONIC_DB_CLI CONFIG_DB SET "CONFIG_DB_INITIALIZED" "0"
261261
else
262+
$SONIC_DB_CLI CONFIG_DB SET "CONFIG_DB_INITIALIZED" "0"
263+
# this is not a first time boot to a new image. Datbase container starts w/ old pre-existing config
264+
if [[ -x /usr/local/bin/db_migrator.py ]]; then
265+
# Migrate the DB to the latest schema version if needed
266+
if [ -z "$DEV" ]; then
267+
/usr/local/bin/db_migrator.py -o migrate
268+
fi
269+
fi
262270
# set CONFIG_DB_INITIALIZED to indicate end of config load and migration
263271
$SONIC_DB_CLI CONFIG_DB SET "CONFIG_DB_INITIALIZED" "1"
264272
fi
273+
265274
# Add redis UDS to the redis group and give read/write access to the group
266275
REDIS_SOCK="/var/run/redis${DEV}/redis.sock"
267276
else

0 commit comments

Comments
 (0)