You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by GitBox <gi...@apache.org> on 2018/03/15 11:02:20 UTC

[GitHub] rhtyd closed pull request #2458: CLOUDSTACK-10296: Find time different from last timestamp

rhtyd closed pull request #2458: CLOUDSTACK-10296: Find time different from last timestamp
URL: https://github.com/apache/cloudstack/pull/2458
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/systemvm/debian/opt/cloud/bin/checkrouter.sh b/systemvm/debian/opt/cloud/bin/checkrouter.sh
index 0a9041bfbd1..bb6c9f8a0f2 100755
--- a/systemvm/debian/opt/cloud/bin/checkrouter.sh
+++ b/systemvm/debian/opt/cloud/bin/checkrouter.sh
@@ -17,6 +17,13 @@
 # under the License.
 
 STATUS=UNKNOWN
+
+if [ "$(systemctl is-active keepalived)" != "active" ]
+then
+    echo "Status: FAULT"
+    exit
+fi
+
 ROUTER_TYPE=$(cat /etc/cloudstack/cmdline.json | grep type | awk '{print $2;}' | sed -e 's/[,\"]//g')
 if [ "$ROUTER_TYPE" = "router" ]
 then
diff --git a/systemvm/debian/opt/cloud/templates/check_heartbeat.sh.templ b/systemvm/debian/opt/cloud/templates/check_heartbeat.sh.templ
index 2ab9abaa8a4..62a2b180e6c 100755
--- a/systemvm/debian/opt/cloud/templates/check_heartbeat.sh.templ
+++ b/systemvm/debian/opt/cloud/templates/check_heartbeat.sh.templ
@@ -16,48 +16,52 @@
 # specific language governing permissions and limitations
 # under the License.
 
-ROUTER_BIN_PATH=/ramdisk/rrouter
-ROUTER_LOG=${ROUTER_BIN_PATH}/keepalived.log
+ROUTER_BIN_PATH="/ramdisk/rrouter"
+ROUTER_LOG="${ROUTER_BIN_PATH}/keepalived.log"
 STRIKE_FILE="$ROUTER_BIN_PATH/keepalived.strikes"
+TS_FILE="$ROUTER_BIN_PATH/keepalived.ts"
+CT_FILE="$ROUTER_BIN_PATH/keepalived.ct"
 
-if [ -e $ROUTER_BIN_PATH/keepalived.ts2 ]
+checktime=$(date +%s)
+hbtime=$(cat $TS_FILE)
+diff=$(($checktime - $hbtime))
+
+lastcheck=0
+if [ -e $CT_FILE ]
+then
+    lastcheck=$(cat $CT_FILE 2>/dev/null)
+fi
+checkdiff=$(($checktime - $lastcheck))
+if [ $checkdiff -ge 0 ] && [ $checkdiff -lt 30 ]
+then
+    exit
+fi
+echo $checktime > $CT_FILE
+
+s=0
+if [ $diff -gt 10 ]
 then
-    thistime=$(cat $ROUTER_BIN_PATH/keepalived.ts)
-    lasttime=$(cat $ROUTER_BIN_PATH/keepalived.ts2)
-    diff=$(($lasttime - $thistime))
-    s=0
-    if [ $diff -ge 10 ]
+    if [ -e $STRIKE_FILE ]
     then
-        if [ -e $STRIKE_FILE ]
-        then
-            s=`cat $STRIKE_FILE 2>/dev/null`
-        fi
-        s=$(($s+1))
-        echo $s > $STRIKE_FILE
-    else
-        if [ -e $STRIKE_FILE ]
-        then
-            rm $STRIKE_FILE
-            echo keepalived.strikes file was removed! >> $ROUTER_LOG
-        else
-            echo keepalived.strikes file does not exist! >> $ROUTER_LOG
-        fi
+        s=$(cat $STRIKE_FILE 2>/dev/null)
     fi
-    #3 strikes rule
-    if [ $s -gt 2 ]
-    then
-        echo Keepalived process is dead! >> $ROUTER_LOG
-        systemctl stop keepalived >> $ROUTER_LOG 2>&1
-        systemctl stop conntrackd >> $ROUTER_LOG 2>&1
+    s=$(($s+1))
+    echo $s > $STRIKE_FILE
+    echo "Check time: $checktime, last heartbeat time: $hbtime, time diff: $diff, strike count: $s" >> $ROUTER_LOG
+else
+    rm -f $STRIKE_FILE
+fi
+
+if [ $s -gt 3 ]
+then
+    systemctl stop --now keepalived >> $ROUTER_LOG 2>&1
+    systemctl stop --now conntrackd >> $ROUTER_LOG 2>&1
 
-        #Set fault so we have the same effect as a KeepaliveD fault.
-        python /opt/cloud/bin/master.py --fault
+    #Set fault so we have the same effect as a KeepaliveD fault.
+    python /opt/cloud/bin/master.py --fault
 
-        pkill -9 keepalived >> $ROUTER_LOG 2>&1
-        pkill -9 conntrackd >> $ROUTER_LOG 2>&1
-        echo Status: FAULT \(keepalived process is dead\) >> $ROUTER_LOG
-        exit
-    fi
+    pkill -9 keepalived >> $ROUTER_LOG 2>&1 || true
+    pkill -9 conntrackd >> $ROUTER_LOG 2>&1 || true
+    echo Status: FAULT \(keepalived process is dead\) >> $ROUTER_LOG
+    exit
 fi
-
-cp $ROUTER_BIN_PATH/keepalived.ts $ROUTER_BIN_PATH/keepalived.ts2


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services