3 # Copyright © 2018 Amdocs
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
18 if [ "$enableDebugLogging" == true ]; then
22 echo $( date ) $@ >> $LOGFILE
28 lockFile=/tmp/sdnc.failover.lock
29 # make sure that no failover is currently running
30 if [ -e ${lockFile} ] && kill -0 $(cat ${lockFile}) 2> /dev/null; then
31 debugLog "Currently running sdnc and dns failover"
34 trap "rm -f ${lockFile}" INT TERM RETURN
35 echo $BASHPID > ${lockFile}
38 debugLog "Started executing sdnc.failover for $SITE_NAME"
39 takeoverResult=$( /app/bin/sdnc.failover )
40 debugLog "Completed executing sdnc.failover. takeoverResult is: $takeoverResult"
41 if [ "success" = "$takeoverResult" ]; then
42 # update CoreDNS upon successful execution of sdnc.failover script
43 debugLog "Executing sdnc.dnsswitch"
44 /app/bin/sdnc.dnsswitch
46 debugLog "Completed executing sdnc.dnsswitch for $SITE_NAME. rc=$rc"
48 debugLog "Cluster takeover current status: $takeoverResult on $SITE_NAME."
53 takeoverResult="failure"
57 \"type\": \"failover\",\
58 \"status\": \"$takeoverResult\",\
59 \"site\": \"$SITE_NAME\",\
60 \"deployment\": \"{{.Values.config.deployment}}\",\
61 \"timestamp\": \"$(date '+%F %T')\"\
64 # notifications are best-effort - ignore any failures
65 curl -H "Content-Type: application/json" -X POST --data "$data" http://$message_router/events/$topic >/dev/null 2>&1
69 LOGFILE="/app/geo.log"
70 enableDebugLogging=true
71 message_router=message-router:3904
72 topic={{.Values.config.messageRouterTopic}}
74 if [ "$SDNC_IS_PRIMARY_CLUSTER" = "false" ];then
79 debugLog "Executing ensureSdncActive"
81 # query SDN-C cluster status
82 debugLog "Started executing sdnc.cluster"
83 clusterStatus=$( /app/bin/sdnc.cluster )
84 debugLog "Completed executing sdnc.cluster. Cluster status is: $clusterStatus"
86 if [ "active" = "$clusterStatus" ]; then
88 debugLog "Started excuting sdnc.monitor"
89 health=$( /app/bin/sdnc.monitor )
90 debugLog "Completed executing sdnc.monitor. Cluster is: $health"
92 if [ "healthy" = "$health" ]; then
93 # Cluster is ACTIVE and HEALTHY
98 elif [ "standby" = "$clusterStatus" ]; then
99 # Run failover in background process and allow PROM to continue
104 # Unknown cluster status