Skip to content
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

VOQ: add dependent peer's stronger dependency with swss to avoid double stop/start and traffic loss #17041

Closed
wants to merge 1 commit into from
Closed
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
52 changes: 48 additions & 4 deletions files/scripts/swss.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ function debug()
/bin/echo `date` "- $1" >> ${DEBUGLOG}
}

function get_switch_type()
{
switch_type=`$SONIC_DB_CLI CONFIG_DB hget 'DEVICE_METADATA|localhost' 'switch_type'`
echo "${switch_type}"
}

function read_dependent_services()
{
# Update dependent list based on other packages requirements
Expand Down Expand Up @@ -124,11 +130,8 @@ function clean_up_tables()
# SYSTEM_LAG_ID_TABLE and SYSTEM_LAG_ID_SET are adjusted appropriately
function clean_up_chassis_db_tables()
{

switch_type=`$SONIC_DB_CLI CONFIG_DB hget 'DEVICE_METADATA|localhost' 'switch_type'`

# Run clean up only in swss running for voq switches
if is_chassis_supervisor || [[ $switch_type != 'voq' ]]; then
if is_chassis_supervisor || [[ $(get_switch_type) != 'voq' ]]; then
return
fi

Expand Down Expand Up @@ -231,11 +234,52 @@ function clean_up_chassis_db_tables()

}

update_peer_systemd_config() {
# Can be extended for pizza box in future
if is_chassis_supervisor || [[ $(get_switch_type) != 'voq' ]]; then
return
fi

local dep_peer=$1
if [[ ! -z $DEV ]]; then
dep_peer=${dep_peer}@$DEV

fi

local systemd_system_dir="/etc/systemd/system/"
local peer_systemd_system_override_dir="${systemd_system_dir}${dep_peer}.service.d/"
local peer_systemd_system_override_dep_file="${peer_systemd_system_override_dir}dependency.conf"

mkdir -p $peer_systemd_system_override_dir
if [[ ! -f $peer_systemd_system_override_dep_file ]]; then
touch $peer_systemd_system_override_dep_file
fi
echo "[Unit]" > $peer_systemd_system_override_dep_file
if [[ ! -z $DEV ]]; then
debug "Updating ${dep_peer} systemd config with Requires=${SERVICE}@${DEV}.service"
echo "Requires=${SERVICE}@${DEV}.service" >> $peer_systemd_system_override_dep_file
else
debug "Updating ${dep_peer} systemd config with Requires=${SERVICE}.service"
echo "Requires=${SERVICE}.service" >> $peer_systemd_system_override_dep_file
fi

#reload systemd config
systemctl daemon-reload
# check if error
if [[ $? -ne 0 ]]; then
echo "Failed to reload systemd config"
exit 1
fi
}

start_peer_and_dependent_services() {
check_warm_boot

if [[ x"$WARM_BOOT" != x"true" ]]; then
for peer in ${PEER}; do
# Update peer systemd config
update_peer_systemd_config ${peer}

if [[ ! -z $DEV ]]; then
/bin/systemctl start ${peer}@$DEV
else
Expand Down
Loading