-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix CONFIG_DB_INITIALIZED flag check logic and set/reset flag for warmboot #15685
Changes from all commits
e6e34db
c05af46
e0d3f0a
65c65e1
678e33e
27baf15
835c923
5779bfc
fdecad1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -235,6 +235,7 @@ function postStartAction() | |
($(docker exec -i database$DEV sonic-db-cli PING | grep -c PONG) -gt 0) ]]; do | ||
sleep 1; | ||
done | ||
|
||
if [[ ("$BOOT_TYPE" == "warm" || "$BOOT_TYPE" == "fastfast" || "$BOOT_TYPE" == "fast") && -f $WARM_DIR/dump.rdb ]]; then | ||
# retain the dump file from last boot for debugging purposes | ||
mv $WARM_DIR/dump.rdb $WARM_DIR/dump.rdb.old | ||
|
@@ -248,28 +249,18 @@ function postStartAction() | |
$SONIC_CFGGEN -j /etc/sonic/config_db$DEV.json --write-to-db | ||
fi | ||
fi | ||
|
||
if [[ "$BOOT_TYPE" == "fast" ]]; then | ||
# set the key to expire in 3 minutes | ||
$SONIC_DB_CLI STATE_DB SET "FAST_REBOOT|system" "1" "EX" "180" | ||
fi | ||
|
||
$SONIC_DB_CLI CONFIG_DB SET "CONFIG_DB_INITIALIZED" "1" | ||
fi | ||
|
||
if [ -e /tmp/pending_config_migration ]; then | ||
if [ -e /tmp/pending_config_migration ] || [ -e /tmp/pending_config_initialization ]; then | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note for reviewer:
Both of these flags are set by rc.local script. |
||
# this is first boot to a new image, config-setup execution is pending. | ||
# For fast/cold reboot case, DB contains nothing at this point | ||
# Call db_migrator after config-setup loads the config (from old config or minigraph) | ||
echo "Delaying db_migrator until config migration is over" | ||
# for warmboot case, DB is loaded but migration is still pending | ||
# For firstbboot/fast/cold reboot case, DB contains nothing at this point | ||
# unset CONFIG_DB_INITIALIZED to indicate pending config load and migration | ||
# 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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note for reviwer: I don't think migration is needed for same-image reboot. For case when device reboots to a different image, but this is not first-time boot to this image: Warm/fast boot: Migration is needed, and old config dump will have old version. But, do we want to support this path, as ideally we expect that the upgrades are always first-time-boot. If this expectation is not true then I can enable the call here for warmboot case. |
||
# 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" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note for reviewer:
This code section is being removed as it will never get called - the check for
fast
reboot will enter the prev parent if block and not this.Moreoever, w/ new changes in fast-boot, we have a dedicated flag for fastboot that gets cleared as part of finalizer. The timed expiry mechanism is not needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just saw this, this is actually crucial for upgrading from older versions prior fast-reboot enhancements.
For example, upgrading from 202012 images, in case it exceeded 180 seconds no indication of fast-reboot is found in STATE-DB and db-migrator will fail to set fast-reboot new notation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right. Thanks for reporting this. The PR was merged when you added comment, and I did not check it.
Fixed this here: #16733