You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by re...@apache.org on 2016/01/16 19:46:21 UTC

[1/3] git commit: updated refs/heads/4.7 to 66a933a

Repository: cloudstack
Updated Branches:
  refs/heads/4.7 b4ebfb640 -> 66a933afa


CLOUDSTACK-9181 Prevent syntax error in checkrouter.sh


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/525949e0
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/525949e0
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/525949e0

Branch: refs/heads/4.7
Commit: 525949e027d89a5c8ef0d1b7012446bb652be659
Parents: 9be76b3
Author: Remi Bergsma <gi...@remi.nl>
Authored: Wed Dec 16 11:27:26 2015 +0100
Committer: Remi Bergsma <gi...@remi.nl>
Committed: Mon Dec 28 17:06:43 2015 +0100

----------------------------------------------------------------------
 systemvm/patches/debian/config/opt/cloud/bin/checkrouter.sh | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/525949e0/systemvm/patches/debian/config/opt/cloud/bin/checkrouter.sh
----------------------------------------------------------------------
diff --git a/systemvm/patches/debian/config/opt/cloud/bin/checkrouter.sh b/systemvm/patches/debian/config/opt/cloud/bin/checkrouter.sh
index 0ba0ee5..f867a48 100755
--- a/systemvm/patches/debian/config/opt/cloud/bin/checkrouter.sh
+++ b/systemvm/patches/debian/config/opt/cloud/bin/checkrouter.sh
@@ -19,19 +19,19 @@
 STATUS=UNKNOWN
 INTERFACE=eth1
 ROUTER_TYPE=$(cat /etc/cloudstack/cmdline.json | grep type | awk '{print $2;}' | sed -e 's/[,\"]//g')
-if [ $ROUTER_TYPE = "router" ]
+if [ "$ROUTER_TYPE" = "router" ]
 then
 	ROUTER_STATE=$(ip addr | grep eth0 | grep inet | wc -l | xargs bash -c  'if [ $0 == 2 ]; then echo "MASTER"; else echo "BACKUP"; fi')
 	STATUS=$ROUTER_STATE
 else
 	ROUTER_STATE=$(ip addr | grep $INTERFACE | grep state | awk '{print $9;}')
-	if [ $ROUTER_STATE = "UP" ]
+	if [ "$ROUTER_STATE" = "UP" ]
 	then
 	    STATUS=MASTER
-	elif [ $ROUTER_STATE = "DOWN" ]
+	elif [ "$ROUTER_STATE" = "DOWN" ]
 	then
 	    STATUS=BACKUP
 	fi
 fi
 
-echo "Status: ${STATUS}"
\ No newline at end of file
+echo "Status: ${STATUS}"


[2/3] git commit: updated refs/heads/4.7 to 66a933a

Posted by re...@apache.org.
make both check lines consistent

No need to make a variable, use it on one place and hardcode it on another.


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/8fb67702
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/8fb67702
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/8fb67702

Branch: refs/heads/4.7
Commit: 8fb677027dc48d034fa9440b125c6bae084266d4
Parents: 525949e
Author: Remi Bergsma <gi...@remi.nl>
Authored: Wed Dec 16 14:45:57 2015 +0100
Committer: Remi Bergsma <gi...@remi.nl>
Committed: Mon Dec 28 17:06:58 2015 +0100

----------------------------------------------------------------------
 systemvm/patches/debian/config/opt/cloud/bin/checkrouter.sh | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/8fb67702/systemvm/patches/debian/config/opt/cloud/bin/checkrouter.sh
----------------------------------------------------------------------
diff --git a/systemvm/patches/debian/config/opt/cloud/bin/checkrouter.sh b/systemvm/patches/debian/config/opt/cloud/bin/checkrouter.sh
index f867a48..0a9041b 100755
--- a/systemvm/patches/debian/config/opt/cloud/bin/checkrouter.sh
+++ b/systemvm/patches/debian/config/opt/cloud/bin/checkrouter.sh
@@ -17,14 +17,13 @@
 # under the License.
 
 STATUS=UNKNOWN
-INTERFACE=eth1
 ROUTER_TYPE=$(cat /etc/cloudstack/cmdline.json | grep type | awk '{print $2;}' | sed -e 's/[,\"]//g')
 if [ "$ROUTER_TYPE" = "router" ]
 then
 	ROUTER_STATE=$(ip addr | grep eth0 | grep inet | wc -l | xargs bash -c  'if [ $0 == 2 ]; then echo "MASTER"; else echo "BACKUP"; fi')
 	STATUS=$ROUTER_STATE
 else
-	ROUTER_STATE=$(ip addr | grep $INTERFACE | grep state | awk '{print $9;}')
+	ROUTER_STATE=$(ip addr | grep eth1 | grep state | awk '{print $9;}')
 	if [ "$ROUTER_STATE" = "UP" ]
 	then
 	    STATUS=MASTER


[3/3] git commit: updated refs/heads/4.7 to 66a933a

Posted by re...@apache.org.
Merge pull request #1296 from remibergsma/fix-checkrouter-script47

CLOUDSTACK-9181 Prevent syntax error in checkrouter.shAdded quotes to prevent syntax errors in weird situations.

Error seen in mgt server:
```
2015-12-15 14:30:32,371 DEBUG [c.c.a.m.AgentManagerImpl] (RedundantRouterStatusMonitor-7:ctx-0dd8ef3e) Details from executing class com.cloud.agent.api.CheckRouterCommand: Status: UNKNOWN
/opt/cloud/bin/checkrouter.sh: line 28: [: =: unary operator expected
/opt/cloud/bin/checkrouter.sh: line 31: [: =: unary operator expected
```
Cause:
```
root@r-1191-VM:/opt/cloud/bin# ./checkrouter.sh
./checkrouter.sh: line 28: [: =: unary operator expected
./checkrouter.sh: line 31: [: =: unary operator expected
Status: UNKNOWN
```

Somehow a nic was missing.

After fix the script can handle this:

```
root@r-1191-VM:/opt/cloud/bin# ./checkrouter.sh
Status: UNKNOWN
```

The other states are also reported fine:
```
root@r-1191-VM:/opt/cloud/bin# ./checkrouter.sh
Status: MASTER
```

```
root@r-1192-VM:/opt/cloud/bin# ./checkrouter.sh
Status: BACKUP
```

While at it, I also removed the INTERFACES variable/constant as it was only used once and hardcoded the second time. Now both are hardcoded and easier to read.

* pr/1296:
  make both check lines consistent
  CLOUDSTACK-9181 Prevent syntax error in checkrouter.sh

Signed-off-by: Remi Bergsma <gi...@remi.nl>


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/66a933af
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/66a933af
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/66a933af

Branch: refs/heads/4.7
Commit: 66a933afab036da48a287cd5f8f1afab53cbd6be
Parents: b4ebfb6 8fb6770
Author: Remi Bergsma <gi...@remi.nl>
Authored: Sat Jan 16 19:46:06 2016 +0100
Committer: Remi Bergsma <gi...@remi.nl>
Committed: Sat Jan 16 19:46:06 2016 +0100

----------------------------------------------------------------------
 .../patches/debian/config/opt/cloud/bin/checkrouter.sh   | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
----------------------------------------------------------------------