Skip to content

Commit

Permalink
Merge pull request #341 from gechiang/202205
Browse files Browse the repository at this point in the history
Wait till CHASIS_APP_DB PING is successful,  host_name and asic_name …
  • Loading branch information
gechiang authored Apr 20, 2024
2 parents 9a0ca72 + 4a48f20 commit a820fe0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
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

0 comments on commit a820fe0

Please sign in to comment.