blob: 94858339e7c6b0f183afe1a69273c49bde063540 [file] [log] [blame]
Krzysztof Opasiakfe651c12021-06-23 10:59:03 +02001#!/bin/bash
Guillaume Lambert62178a42021-03-08 21:38:31 +01002{{/*
Krzysztof Opasiakfe651c12021-06-23 10:59:03 +02003
Mohammadreza Pasandidehb642ee52018-06-19 15:19:53 -04004# Copyright © 2018 Amdocs
5#
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
9#
10# http://www.apache.org/licenses/LICENSE-2.0
11#
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.
Jakub Latuseke0e8ca72020-10-21 13:36:29 +020017*/}}
Mohammadreza Pasandidehb642ee52018-06-19 15:19:53 -040018
19debugLog(){
Guillaume Lambert5f4af052021-03-09 21:52:32 +010020 if [ "$enableDebugLogging" = true ]; then
Mohammadreza Pasandidehb642ee52018-06-19 15:19:53 -040021 if [ $# -eq 0 ]; then
22 echo "" >> $LOGFILE
23 else
24 echo $( date ) $@ >> $LOGFILE
25 fi
26 fi
27}
28
29LOGFILE="/app/geo.log"
30enableDebugLogging=true
31
32debugLog
33debugLog "Executing ensureSdncStandby"
34
35# query SDN-C cluster status
36debugLog "Started executing sdnc.cluster"
37clusterStatus=$( /app/bin/sdnc.cluster )
38debugLog "Completed executing sdnc.cluster. Cluster status is: $clusterStatus"
39
40if [ "active" = "$clusterStatus" ]; then
41 # assume transient error as other side transitions to ACTIVE
42 debugLog "Cluster status: $clusterStatus. exit 0"
43 exit 0
44
45elif [ "standby" = "$clusterStatus" ]; then
46 # check that standby cluster is healthy
47 debugLog "Started executing sdnc.monitor. Cluster status is: $clusterStatus"
48 health=$( /app/bin/sdnc.monitor )
49 debugLog "Completed executing sdnc.monitor. Cluster is: $health"
50 if [ "failure" = "$health" ];then
51 # Backup site is unhealthy - can't accept traffic!
52 exit 1
53 fi
54 # Cluster is standing by
55 exit 0
56fi
57
58debugLog "Unknown cluster status: $clusterStatus"
59# Unknown cluster status
60exit 1