Skip to content

Commit

Permalink
Run db_migrator for non first-time reboots (sonic-net#16116)
Browse files Browse the repository at this point in the history
- 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 <vkarri@nvidia.com>
  • Loading branch information
vivekrnv authored and mssonicbld committed Aug 28, 2023
1 parent e7ce179 commit 01402ff
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions files/build_templates/docker_image_ctl.j2
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,18 @@ function postStartAction()
# This flag will be set to "1" after DB migration/initialization is completed as part of config-setup
$SONIC_DB_CLI CONFIG_DB SET "CONFIG_DB_INITIALIZED" "0"
else
$SONIC_DB_CLI CONFIG_DB SET "CONFIG_DB_INITIALIZED" "0"
# 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
# set CONFIG_DB_INITIALIZED to indicate end of config load and migration
$SONIC_DB_CLI CONFIG_DB SET "CONFIG_DB_INITIALIZED" "1"
fi

# Add redis UDS to the redis group and give read/write access to the group
REDIS_SOCK="/var/run/redis${DEV}/redis.sock"
else
Expand Down

0 comments on commit 01402ff

Please sign in to comment.