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

[action] [PR:17962] Wait till CHASIS_APP_DB PING is successful, host_name and asic_name are valid in CONIFG_DB before starting chassis-db-cleanup (#17962) #18756

Merged
merged 1 commit into from
Apr 23, 2024
Merged
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
8 changes: 7 additions & 1 deletion files/image_config/hostname/hostname-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,16 @@ fi
echo $HOSTNAME > /etc/hostname
hostname -F /etc/hostname

#Don't update the /etc/hosts if hostname is not changed
#This is to prevent intermittent redis_chassis.server reachability issue
if [ $CURRENT_HOSTNAME == $HOSTNAME ] ; then
exit 0
fi

# Remove the old hostname entry from hosts file.
# But, 'localhost' entry is used by multiple applications. Don't remove it altogether.
# Edit contents of /etc/hosts and put in /etc/hosts.new
if [ $CURRENT_HOSTNAME != "localhost" ] || [ $CURRENT_HOSTNAME == $HOSTNAME ] ; then
if [ $CURRENT_HOSTNAME != "localhost" ] ; then
sed "/\s$CURRENT_HOSTNAME$/d" /etc/hosts > /etc/hosts.new
else
cp -f /etc/hosts /etc/hosts.new
Expand Down
17 changes: 14 additions & 3 deletions files/scripts/swss.sh
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,23 @@ function clean_up_chassis_db_tables()
return
fi

if [[ !($($SONIC_DB_CLI CHASSIS_APP_DB PING | grep -c True) -gt 0) ]]; then
return
fi
until [[ $($SONIC_DB_CLI CHASSIS_APP_DB PING | grep -c True) -gt 0 ]]; do
sleep 1
done

lc=`$SONIC_DB_CLI CONFIG_DB hget 'DEVICE_METADATA|localhost' 'hostname'`
until [[ -n "${lc}" ]]; do
lc=`$SONIC_DB_CLI CONFIG_DB hget 'DEVICE_METADATA|localhost' 'hostname'`
sleep 1
done
debug "Chassis db clean up for ${SERVICE}$DEV. hostname=$lc"

asic=`$SONIC_DB_CLI CONFIG_DB hget 'DEVICE_METADATA|localhost' 'asic_name'`
until [[ -n "${asic}" ]]; do
asic=`$SONIC_DB_CLI CONFIG_DB hget 'DEVICE_METADATA|localhost' 'asic_name'`
sleep 1
done
debug "Chassis db clean up for ${SERVICE}$DEV. asic=$asic"

# First, delete SYSTEM_NEIGH entries
num_neigh=`$SONIC_DB_CLI CHASSIS_APP_DB EVAL "
Expand Down
Loading