Skip to content

Commit a820fe0

Browse files
authored
Merge pull request sonic-net#341 from gechiang/202205
Wait till CHASIS_APP_DB PING is successful, host_name and asic_name …
2 parents 9a0ca72 + 4a48f20 commit a820fe0

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

files/image_config/hostname/hostname-config.sh

+7-1
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,16 @@ fi
1111
echo $HOSTNAME > /etc/hostname
1212
hostname -F /etc/hostname
1313

14+
#Don't update the /etc/hosts if hostname is not changed
15+
#This is to prevent intermittent redis_chassis.server reachability issue
16+
if [ $CURRENT_HOSTNAME == $HOSTNAME ] ; then
17+
exit 0
18+
fi
19+
1420
# Remove the old hostname entry from hosts file.
1521
# But, 'localhost' entry is used by multiple applications. Don't remove it altogether.
1622
# Edit contents of /etc/hosts and put in /etc/hosts.new
17-
if [ $CURRENT_HOSTNAME != "localhost" ] || [ $CURRENT_HOSTNAME == $HOSTNAME ] ; then
23+
if [ $CURRENT_HOSTNAME != "localhost" ] ; then
1824
sed "/\s$CURRENT_HOSTNAME$/d" /etc/hosts > /etc/hosts.new
1925
else
2026
cp -f /etc/hosts /etc/hosts.new

files/scripts/swss.sh

+14-3
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,23 @@ function clean_up_chassis_db_tables()
132132
return
133133
fi
134134

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

139139
lc=`$SONIC_DB_CLI CONFIG_DB hget 'DEVICE_METADATA|localhost' 'hostname'`
140+
until [[ -n "${lc}" ]]; do
141+
lc=`$SONIC_DB_CLI CONFIG_DB hget 'DEVICE_METADATA|localhost' 'hostname'`
142+
sleep 1
143+
done
144+
debug "Chassis db clean up for ${SERVICE}$DEV. hostname=$lc"
145+
140146
asic=`$SONIC_DB_CLI CONFIG_DB hget 'DEVICE_METADATA|localhost' 'asic_name'`
147+
until [[ -n "${asic}" ]]; do
148+
asic=`$SONIC_DB_CLI CONFIG_DB hget 'DEVICE_METADATA|localhost' 'asic_name'`
149+
sleep 1
150+
done
151+
debug "Chassis db clean up for ${SERVICE}$DEV. asic=$asic"
141152

142153
# First, delete SYSTEM_NEIGH entries
143154
num_neigh=`$SONIC_DB_CLI CHASSIS_APP_DB EVAL "

0 commit comments

Comments
 (0)