From 5b3c99031ffa1e2f73fc839d054cb88f6abd802b Mon Sep 17 00:00:00 2001 From: Wilder Rodrigues Date: Sat, 17 Oct 2015 08:09:52 +0200 Subject: [PATCH] CLOUDSTACK-8952 - Do not rely in the router state on the json file to report back to ACS - If we stop/start a router, the state in the file will still say MASTER, when it is actually not - Checking the state based on the interface (eth1) state - Once master.py is called by keepalived, save the state in the json file to BACKUP just to make sure it's also written there --- .../patches/debian/config/opt/cloud/bin/checkrouter.sh | 9 +++++---- systemvm/patches/debian/config/opt/cloud/bin/master.py | 2 ++ .../config/opt/cloud/templates/checkrouter.sh.templ | 9 +++++---- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/systemvm/patches/debian/config/opt/cloud/bin/checkrouter.sh b/systemvm/patches/debian/config/opt/cloud/bin/checkrouter.sh index 12b2da4e62d..1e4335c0fcc 100755 --- a/systemvm/patches/debian/config/opt/cloud/bin/checkrouter.sh +++ b/systemvm/patches/debian/config/opt/cloud/bin/checkrouter.sh @@ -16,9 +16,10 @@ # specific language governing permissions and limitations # under the License. -STATUS=$(cat /etc/cloudstack/cmdline.json | grep redundant_state | awk '{print $2;}' | sed -e 's/[,\"]//g') -if [ "$?" -ne "0" ] +STATUS=BACKUP +ETH1_STATE=$(ip addr | grep eth1 | grep state | awk '{print $9;}') +if [ $ETH1_STATE = "UP" ] then - STATUS=MASTER + STATUS=MASTER fi -echo "Status: ${STATUS}" +echo "Status: ${STATUS}" \ No newline at end of file diff --git a/systemvm/patches/debian/config/opt/cloud/bin/master.py b/systemvm/patches/debian/config/opt/cloud/bin/master.py index fb6ef6a6f9d..c3a1539688d 100755 --- a/systemvm/patches/debian/config/opt/cloud/bin/master.py +++ b/systemvm/patches/debian/config/opt/cloud/bin/master.py @@ -42,7 +42,9 @@ logging.basicConfig(filename=config.get_logger(), format=config.get_format()) config.cmdline() cl = CsCmdLine("cmdline", config) +#Update the configuration to set state as backup and let keepalived decide who is the real Master cl.set_master_state(False) +cl.save() config.set_address() red = CsRedundant(config) diff --git a/systemvm/patches/debian/config/opt/cloud/templates/checkrouter.sh.templ b/systemvm/patches/debian/config/opt/cloud/templates/checkrouter.sh.templ index 12b2da4e62d..1e4335c0fcc 100755 --- a/systemvm/patches/debian/config/opt/cloud/templates/checkrouter.sh.templ +++ b/systemvm/patches/debian/config/opt/cloud/templates/checkrouter.sh.templ @@ -16,9 +16,10 @@ # specific language governing permissions and limitations # under the License. -STATUS=$(cat /etc/cloudstack/cmdline.json | grep redundant_state | awk '{print $2;}' | sed -e 's/[,\"]//g') -if [ "$?" -ne "0" ] +STATUS=BACKUP +ETH1_STATE=$(ip addr | grep eth1 | grep state | awk '{print $9;}') +if [ $ETH1_STATE = "UP" ] then - STATUS=MASTER + STATUS=MASTER fi -echo "Status: ${STATUS}" +echo "Status: ${STATUS}" \ No newline at end of file