4 # Copyright © 2018 Amdocs
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
10 # http://www.apache.org/licenses/LICENSE-2.0
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
19 LOGFILE="/app/geo.log"
20 enableDebugLogging=true
21 message_router=message-router:3904
22 topic={{.Values.config.messageRouterTopic}}
23 KEYWORD_success="success"
24 KEYWORD_failure="failure"
26 if [ "$SDNC_IS_PRIMARY_CLUSTER" = "false" ];then
33 if [ "$enableDebugLogging" == true ]; then
37 echo $( date ) $@ >> $LOGFILE
42 EXC_SIMPLE_FAILOVER=`${APP_BIN}/switchVoting.sh`
44 if [ "$EXC_SIMPLE_FAILOVER" == "success" ]; then
45 debugLog "Simple failover success. SDNC failover completed."
47 # Simple failover failed. Trying catastrophic failover ...
48 debugLog "Simple failover failed. Trying catastrophic failover for $SITE_NAME ..."
50 # Notify Dmaap before executing catastrophic failover, because all connections will be reset.
52 \"type\": \"Catastrophic failover\",\
53 \"reason\": \"Simple failover failed\",\
54 \"message_router\": \"$message_router\",\
55 \"topic\": \"$topic\",\
56 \"site\": \"$SITE_NAME\",\
57 \"deployment\": \"{{.Values.config.deployment}}\",\
58 \"timestamp\": \"$(date '+%F %T')\"\
63 # notifications to Dmaap
64 curl -H "Content-Type: application/json" -X POST --data "$data" http://$message_router/events/$topic >/dev/null 2>&1
66 # We're going to kill prom, so we need to do dnsswitch now
68 debugLog "Executing sdnc.dnsswitch"
70 /app/bin/sdnc.dnsswitch > /dev/null 2>&1
73 debugLog "sdnc.dnsswitch FAILED"
78 # Now do catastrophic failure
80 debugLog "Catastrophic failover in progress"
82 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
84 # Sleep here so prom can die without us passing control back to ensureSDNCActive