Skip to content

Commit

Permalink
Fixes: HA:cmon restarts haproxy every few hours in HA setup
Browse files Browse the repository at this point in the history
Connections to the standby instance of HAP should not be created.
Fix provides a way to check for this and restart HAP with the
intention that apps will reconnect to the right HAP instance

Change-Id: Iba8340ecfee1b2edd118d19ebcbe1eb919e68822
Closes-Bug: #1581905
  • Loading branch information
Ranjeet R committed Nov 17, 2016
1 parent c12d732 commit d7e9822
Showing 1 changed file with 11 additions and 18 deletions.
29 changes: 11 additions & 18 deletions contrail_provisioning/openstack/scripts/contrail-cmon-monitor.sh
Expand Up @@ -166,11 +166,9 @@ verify_cmon() {
cmon=$CMON_SVC_CHECK
cmonpid=$(pidof cmon)
if [ $cmon == $cmonpid ] && [ -n "$cmonpid" ]; then
log_info_msg "CMON is Running"
echo "y"
return 1
else
log_info_msg "CMON is not Running"
echo "n"
return 0
fi
Expand Down Expand Up @@ -286,37 +284,32 @@ if [ $viponme == 0 ]; then
hapid=$(pidof haproxy)
for (( i=0; i<${DIPS_SIZE}; i++ ))
do
dipsonnonvip=$(lsof -p $hapid | grep ${DIPS[i]} | awk '{print $9}')
if [[ -n "$dipsonnonvip" ]]; then
dipsonnonvip=$(lsof -p $hapid | grep ${DIPS[i]} | awk '{print $9}' | wc -l)
if [[ $dipsonnonvip -ne 0 ]] && [[-n "$dipsonnonvip" ]]; then
dipsonvipdumpip=$(lsof -p $hapid | grep ${DIPS[i]} | awk '{print $9}')
haprestart=1
break
fi
done

for (( i=0; i<${DIPS_HOST_SIZE}; i++ ))
do
dipsonnonvip=$(lsof -p $hapid | grep ${DIPHOSTS[i]} | awk '{print $9}')
if [[ -n "$dipsonnonvip" ]]; then
dipsonnonvip=$(lsof -p $hapid | grep ${DIPHOSTS[i]} | awk '{print $9}' | wc -l)
if [[ $dipsonnonvip -ne 0 ]] && [[-n "$dipsonnonvip" ]]; then
dipsonvipdumphosts=$(lsof -p $hapid | grep ${DIPHOSTS[i]} | awk '{print $9}')
haprestart=1
break
fi
done

if [ $haprestart -eq 1 ]; then
(exec $HAP_RESTART)&
log_info_msg "Restarted HAP becuase of stale dips"
log_error_msg "connections to backends from this HAP instance:"
log_error_msg "$dipsonvipdumpip"
log_error_msg "$dipsonvipdumphosts"
#(exec $HAP_RESTART)&
#log_info_msg "Restarted HAP becuase of stale dips"
fi
fi

if [ -f $cleanuppending ]; then
(exec rm -rf $cleanuppending)&
fi
if [ -f $rstcnt ]; then
(exec rm -rf $rstcnt)&
fi
if [ -f $numrst ]; then
(exec rm -rf $numrst)&
fi
}

cleanup() {
Expand Down

0 comments on commit d7e9822

Please sign in to comment.