This repository has been archived on 2025-03-20. You can view files and clone it, but cannot push or open issues or pull requests.
sonic-buildimage/files
Vaibhav Hemant Dixit 908933bd8c
[202012] Fix CONFIG_DB_INITIALIZED flag check logic and set/reset flag for warmboot (#16225)
Cherry pick of #15685

MSFT ADO: 24274591

#### Why I did it

Two changes:
### 1  Fix a day1 issue, where check to wait until `CONFIG_DB_INITIALIZED` is incorrect.
There are multiple places where same incorrect logic is used.

Current logic (`until [[ $($SONIC_DB_CLI CONFIG_DB GET "CONFIG_DB_INITIALIZED") ]];`) will always result in pass, irrespective of the result of GET operation.
```
root@str2-7060cx-32s-29:~# sonic-db-cli CONFIG_DB GET "CONFIG_DB_INITIALIZED"
1
root@str2-7060cx-32s-29:~# until [[ $(sonic-db-cli CONFIG_DB GET "CONFIG_DB_INITIALIZED") ]]; do echo "entered here"; done
root@str2-7060cx-32s-29:~# 

root@str2-7060cx-32s-29:~# 
root@str2-7060cx-32s-29:~# sonic-db-cli CONFIG_DB GET "CONFIG_DB_INITIALIZED"                                             
0
root@str2-7060cx-32s-29:~# until [[ $(sonic-db-cli CONFIG_DB GET "CONFIG_DB_INITIALIZED") ]]; do echo "entered here"; done
root@str2-7060cx-32s-29:~# 
```

Fix this logic by checking for value of flag to be "1".
```
root@str2-7060cx-32s-29:~# until [[ $(sonic-db-cli CONFIG_DB GET "CONFIG_DB_INITIALIZED") -eq 1 ]]; do echo "entered here"; done
entered here
entered here
entered here
```

This gap in logic was highlighted when another fix was merged: https://github.com/sonic-net/sonic-buildimage/pull/14933
The issue being fixed here caused warmboot-finalizer to not wait until config-db is initialized.

### 2 Set and unset CONFIG_DB_INITIALIZED for warm-reboot case

Currently, during warm shutdown `CONFIG_DB_INITIALIZED`'s value is stored in redis db backup. This is restored back when the dump is loaded during warm-recovery.
So the value of `CONFIG_DB_INITIALIZED` does not depend on config db's state, however it remain what it was before reboot.

Fix this by setting `CONFIG_DB_INITIALIZED` to 0 as when the DB is loaded, and set it to 1 after db_migrator is done.
2023-08-24 11:48:56 -07:00
..
Aboot [Arista] Disable SSD NCQ on Lodoga (#13964) 2023-04-27 12:33:38 +08:00
apt [Build][202012] Support Debian snapshot mirror to improve build stability (#14558) 2023-04-20 22:45:33 -07:00
build/versions [ci/build]: Upgrade SONiC package versions 2023-05-10 20:50:40 +08:00
build_scripts [hostcfgd]: Add Ability To Configure Feature During Run-time (#6700) 2021-03-15 19:09:31 -07:00
build_templates [202012] Fix CONFIG_DB_INITIALIZED flag check logic and set/reset flag for warmboot (#16225) 2023-08-24 11:48:56 -07:00
dhcp ZTP infrastructure changes to support DHCP discovery provisioning data (#3298) 2019-12-10 08:16:56 -08:00
docker Enabling ipv6 support on docker container network. This is needed (#5418) 2020-09-22 08:32:17 -07:00
image_config [202012] Fix CONFIG_DB_INITIALIZED flag check logic and set/reset flag for warmboot (#16225) 2023-08-24 11:48:56 -07:00
initramfs-tools [Arista] Fix arista-net initramfs hook (#10626) 2022-04-20 10:03:37 -07:00
scripts [202012] Fix CONFIG_DB_INITIALIZED flag check logic and set/reset flag for warmboot (#16225) 2023-08-24 11:48:56 -07:00
sshd Remove SSH host keys after installing the custom version of sshd (#10633) (#11140) 2022-06-16 11:47:04 -07:00