Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions files/image_config/config-setup/config-setup
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,23 @@ ztp_is_enabled()
return $rv
}

set_config_db_initialized()
{
local value="$1"
local asic_num=0

sonic-db-cli CONFIG_DB SET "CONFIG_DB_INITIALIZED" "$value"

if [[ ${NUM_ASIC:-1} -le 1 ]]; then
return 0
fi

while [[ $asic_num -lt $NUM_ASIC ]]; do
sonic-db-cli -n "asic$asic_num" CONFIG_DB SET "CONFIG_DB_INITIALIZED" "$value"
((asic_num = asic_num + 1))
done
}

# Generate requested SONiC configuration and save it as destination file
# Usage: generate_config < factory | ztp > <destination_file>
#
Expand Down Expand Up @@ -367,7 +384,7 @@ do_db_migration()
# Migrate the DB to the latest schema version if needed
/usr/local/bin/db_migrator.py -o migrate
fi
sonic-db-cli CONFIG_DB SET "CONFIG_DB_INITIALIZED" "1"
set_config_db_initialized "1"

#Enforce CHASSIS_APP_DB.tsa_enabled to be in sync with BGP_DEVICE_GLOBAL.STATE.tsa_enabled
if [[ -f /etc/sonic/chassisdb.conf ]] && [[ $disaggregated_chassis -ne 1 ]]; then
Expand Down Expand Up @@ -454,7 +471,7 @@ boot_config()
echo "Warm boot detected, skipping config initialization and ZTP."
# Mark config as initialized so subsequent boots don't re-trigger
# initialization unnecessarily (warm-reboot to new image scenario).
sonic-db-cli CONFIG_DB SET "CONFIG_DB_INITIALIZED" "1"
set_config_db_initialized "1"
rm -f /etc/sonic/pending_config_initialization
return 0
fi
Expand Down
2 changes: 1 addition & 1 deletion files/scripts/bgp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function validate_restore_count()

function check_fast_boot ()
{
SYSTEM_FAST_REBOOT=`sonic-db-cli STATE_DB hget "FAST_RESTART_ENABLE_TABLE|system" enable`
SYSTEM_FAST_REBOOT=`$SONIC_DB_CLI STATE_DB hget "FAST_RESTART_ENABLE_TABLE|system" enable`
if [[ x"${SYSTEM_FAST_REBOOT}" == x"true" ]]; then
FAST_BOOT="true"
else
Expand Down
2 changes: 1 addition & 1 deletion files/scripts/bmp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function check_warm_boot()

function check_fast_boot ()
{
SYSTEM_FAST_REBOOT=`sonic-db-cli STATE_DB hget "FAST_RESTART_ENABLE_TABLE|system" enable`
SYSTEM_FAST_REBOOT=`$SONIC_DB_CLI STATE_DB hget "FAST_RESTART_ENABLE_TABLE|system" enable`
if [[ x"${SYSTEM_FAST_REBOOT}" == x"true" ]]; then
FAST_BOOT="true"
else
Expand Down
2 changes: 1 addition & 1 deletion files/scripts/service_mgmt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function check_warm_boot()

function check_fast_boot ()
{
SYSTEM_FAST_REBOOT=`sonic-db-cli STATE_DB hget "FAST_RESTART_ENABLE_TABLE|system" enable`
SYSTEM_FAST_REBOOT=`$SONIC_DB_CLI STATE_DB hget "FAST_RESTART_ENABLE_TABLE|system" enable`
if [[ x"${SYSTEM_FAST_REBOOT}" == x"true" ]]; then
FAST_BOOT="true"
else
Expand Down
8 changes: 4 additions & 4 deletions files/scripts/swss.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function check_warm_boot()

function check_fast_boot()
{
SYSTEM_FAST_REBOOT=`sonic-db-cli STATE_DB hget "FAST_RESTART_ENABLE_TABLE|system" enable`
SYSTEM_FAST_REBOOT=`$SONIC_DB_CLI STATE_DB hget "FAST_RESTART_ENABLE_TABLE|system" enable`
if [[ x"${SYSTEM_FAST_REBOOT}" == x"true" ]]; then
FAST_BOOT="true"
else
Expand Down Expand Up @@ -539,8 +539,8 @@ stop() {
clean_up_tables STATE_DB "'FABRIC_PORT_TABLE*'"
debug "Cleared FABRIC_PORT_TABLE from STATE_DB for ${SERVICE}$DEV..."
else
debug "Killing Docker swss..."
/usr/bin/docker kill swss &> /dev/null || debug "Docker swss is not running ($?) ..."
debug "Killing Docker ${SERVICE}$DEV..."
/usr/bin/docker kill ${SERVICE}$DEV &> /dev/null || debug "Docker ${SERVICE}$DEV is not running ($?) ..."
fi

# Flush FAST_REBOOT table when swss needs to stop. The only
Expand All @@ -549,7 +549,7 @@ stop() {
# be restarted.
if [[ x"$FAST_BOOT" != x"true" ]]; then
debug "Clearing FAST_RESTART_ENABLE_TABLE flag..."
sonic-db-cli STATE_DB hset "FAST_RESTART_ENABLE_TABLE|system" "enable" "false"
$SONIC_DB_CLI STATE_DB hset "FAST_RESTART_ENABLE_TABLE|system" "enable" "false"
fi
# Unlock has to happen before reaching out to peer service
unlock_service_state_change
Expand Down
4 changes: 2 additions & 2 deletions files/scripts/syncd_common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function check_warm_boot()

function check_fast_boot()
{
SYSTEM_FAST_REBOOT=`sonic-db-cli STATE_DB hget "FAST_RESTART_ENABLE_TABLE|system" enable`
SYSTEM_FAST_REBOOT=`$SONIC_DB_CLI STATE_DB hget "FAST_RESTART_ENABLE_TABLE|system" enable`
if [[ x"${SYSTEM_FAST_REBOOT}" == x"true" ]]; then
FAST_BOOT="true"
else
Expand Down Expand Up @@ -88,7 +88,7 @@ function getBootType()
;;
*SONIC_BOOT_TYPE=fast*|*fast-reboot*)
# check that the key exists
SYSTEM_FAST_REBOOT=`sonic-db-cli STATE_DB hget "FAST_RESTART_ENABLE_TABLE|system" enable`
SYSTEM_FAST_REBOOT=`$SONIC_DB_CLI STATE_DB hget "FAST_RESTART_ENABLE_TABLE|system" enable`
if [[ x"${SYSTEM_FAST_REBOOT}" == x"true" ]]; then
TYPE='fast'
else
Expand Down
2 changes: 1 addition & 1 deletion files/scripts/teamd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function validate_restore_count()

function check_fast_boot ()
{
SYSTEM_FAST_REBOOT=`sonic-db-cli STATE_DB hget "FAST_RESTART_ENABLE_TABLE|system" enable`
SYSTEM_FAST_REBOOT=`$SONIC_DB_CLI STATE_DB hget "FAST_RESTART_ENABLE_TABLE|system" enable`
if [[ x"${SYSTEM_FAST_REBOOT}" == x"true" ]]; then
FAST_BOOT="true"
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ pub async fn wait_for_container(
if dependent_services.contains(&container_name) {
let (service_name, namespace) = parse_container_name(&container_name);
let warm_restart = device_info::is_warm_restart_enabled_in_namespace(service_name, &namespace)?;
let fast_reboot = device_info::is_fast_reboot_enabled()?;
let fast_reboot = device_info::is_fast_reboot_enabled_in_namespace(&namespace)?;

if warm_restart || fast_reboot {
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ async fn test_teamd_exits_warm_restart_main_will_not_exit() {
returns: Ok(true)
));
injector
.when_called(func!(sonic_rs_common::device_info::is_fast_reboot_enabled, fn() -> Result<bool, sonic_rs_common::device_info::DeviceInfoError>))
.when_called(func!(sonic_rs_common::device_info::is_fast_reboot_enabled_in_namespace, fn(&str) -> Result<bool, sonic_rs_common::device_info::DeviceInfoError>))
.will_execute(fake!(
func_type: fn() -> Result<bool, sonic_rs_common::device_info::DeviceInfoError>,
returns: Ok(false)
Expand Down
6 changes: 6 additions & 0 deletions src/sonic-rs-common/src/device_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,10 @@ pub fn is_fast_reboot_enabled() -> Result<bool> {
let state_db = StateDBConnector::new()
.map_err(|e| DeviceInfoError::SwSS(e))?;
is_fast_reboot_enabled_with_db(&state_db)
}

pub fn is_fast_reboot_enabled_in_namespace(namespace: &str) -> Result<bool> {
let state_db = StateDBConnector::new_with_namespace(namespace)
.map_err(|e| DeviceInfoError::SwSS(e))?;
is_fast_reboot_enabled_with_db(&state_db)
}
Loading