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.
17 LOGFILE="/app/geo.log"
18 enableDebugLogging=true
19 message_router=message-router:3904
20 topic={{.Values.config.messageRouterTopic}}
21 KEYWORD_success="success"
22 KEYWORD_failure="failure"
24 if [ "$SDNC_IS_PRIMARY_CLUSTER" = "false" ];then
31 if [ "$enableDebugLogging" == true ]; then
35 echo $( date ) $@ >> $LOGFILE
40 EXC_SIMPLE_FAILOVER=`${APP_BIN}/switchVoting.sh`
42 if [ "$EXC_SIMPLE_FAILOVER" == "success" ]; then
43 debugLog "Simple failover success. SDNC failover completed."
45 # Simple failover failed. Trying catastrophic failover ...
46 debugLog "Simple failover failed. Trying catastrophic failover for $SITE_NAME ..."
48 # Notify Dmaap before executing catastrophic failover, because all connections will be reset.
50 \"type\": \"Catastrophic failover\",\
51 \"reason\": \"Simple failover failed\",\
52 \"message_router\": \"$message_router\",\
53 \"topic\": \"$topic\",\
54 \"site\": \"$SITE_NAME\",\
55 \"deployment\": \"{{.Values.config.deployment}}\",\
56 \"timestamp\": \"$(date '+%F %T')\"\
61 # notifications to Dmaap
62 curl -H "Content-Type: application/json" -X POST --data "$data" http://$message_router/events/$topic >/dev/null 2>&1
64 # We're going to kill prom, so we need to do dnsswitch now
66 debugLog "Executing sdnc.dnsswitch"
68 /app/bin/sdnc.dnsswitch > /dev/null 2>&1
71 debugLog "sdnc.dnsswitch FAILED"
76 # Now do catastrophic failure
78 debugLog "Catastrophic failover in progress"
80 ssh -o StrictHostKeyChecking=no -i /app/config/coredns/master.key root@$SDNC_LOCAL_K8S_CLUSTER_MASTER "su - ubuntu bash -c 'helm upgrade --set sdnc.config.geoEnabled=false dev local/onap --namespace onap; kubectl -n onap delete pods -l app=sdnc'" > /dev/null 2>&1
82 # Sleep here so prom can die without us passing control back to ensureSDNCActive