From fcc52d535491b2d79c9c346b534294ed03dbc350 Mon Sep 17 00:00:00 2001 From: Vivek Reddy Karri Date: Fri, 11 Aug 2023 00:40:02 +0000 Subject: [PATCH 1/3] Run db_migrator for non first-time reboots Signed-off-by: Vivek Reddy Karri --- files/build_templates/docker_image_ctl.j2 | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/files/build_templates/docker_image_ctl.j2 b/files/build_templates/docker_image_ctl.j2 index 924f0283bad..aeab13e09bc 100644 --- a/files/build_templates/docker_image_ctl.j2 +++ b/files/build_templates/docker_image_ctl.j2 @@ -259,6 +259,13 @@ 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 + # 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 From 861a3dbdf2587875d0df8af8dc9f69f3f5237b20 Mon Sep 17 00:00:00 2001 From: Vivek Reddy Karri Date: Fri, 11 Aug 2023 06:47:18 +0000 Subject: [PATCH 2/3] Add the INIT flag before running db-migrator Signed-off-by: Vivek Reddy Karri --- files/build_templates/docker_image_ctl.j2 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/files/build_templates/docker_image_ctl.j2 b/files/build_templates/docker_image_ctl.j2 index aeab13e09bc..c7ed13f4e33 100644 --- a/files/build_templates/docker_image_ctl.j2 +++ b/files/build_templates/docker_image_ctl.j2 @@ -259,6 +259,9 @@ 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 + if [[ ("$BOOT_TYPE" != "warm" ]]; then + $SONIC_DB_CLI CONFIG_DB SET "CONFIG_DB_INITIALIZED" "0" + fi # 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 From 7cfa2f350522f14661bb5dfa8bb1d5bda7bbadd7 Mon Sep 17 00:00:00 2001 From: Vivek Reddy Karri Date: Fri, 11 Aug 2023 06:52:54 +0000 Subject: [PATCH 3/3] Minor mistake Signed-off-by: Vivek Reddy Karri --- files/build_templates/docker_image_ctl.j2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/build_templates/docker_image_ctl.j2 b/files/build_templates/docker_image_ctl.j2 index c7ed13f4e33..53f8ff8e444 100644 --- a/files/build_templates/docker_image_ctl.j2 +++ b/files/build_templates/docker_image_ctl.j2 @@ -259,7 +259,7 @@ 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 - if [[ ("$BOOT_TYPE" != "warm" ]]; then + if [[ "$BOOT_TYPE" != "warm" ]]; then $SONIC_DB_CLI CONFIG_DB SET "CONFIG_DB_INITIALIZED" "0" fi # this is not a first time boot to a new image. Datbase container starts w/ old pre-existing config