[ovs-dev] [PATCH] ovn-ctl: Handle whitespaces when using eval for start_ovsdb:

aginwala amginwal at gmail.com
Tue Apr 17 04:18:43 UTC 2018


eval doesn't understand white space for local var which was introduced in commit
79c7961b8b3c4b7ea0251dea2ffacfa84c84fecb for starting clustered ovn dbs.
As ovn-ctl uses sh instead of bash, parsing local var with white space will fail.

e.g. /usr/share/openvswitch/scripts/ovn-ctl --db-nb-addr=192.168.220.101 --db-nb-create-insecure-remote=yes \
     --db-sb-addr=192.168.220.101 --db-sb-create-insecure-remote=yes \
     --db-nb-cluster-local-addr=192.168.220.101 \
     --db-sb-cluster-local-addr=192.168.220.101 \
     --ovn-northd-nb-db=tcp:192.168.220.101:6641,tcp:192.168.220.102:6641,tcp:192.168.220.103:6641 \
     --ovn-northd-sb-db=tcp:192.168.220.101:6642,tcp:192.168.220.102:6642,tcp:192.168.220.103:6642 \
     start_northd

gives error: /usr/share/openvswitch/scripts/ovn-ctl: 1: local: -vfile:info: bad variable name

As a result ovsdb fails to even initialize and start. Hence, we need to remove
local keyword for all variables used with eval to make it work with both dash and bash.

Signed-off-by: aginwala <aginwala at ebay.com>
---
 ovn/utilities/ovn-ctl | 40 ++++++++++++++++++++--------------------
 1 file changed, 20 insertions(+), 20 deletions(-)

diff --git a/ovn/utilities/ovn-ctl b/ovn/utilities/ovn-ctl
index 25dda52..249522e 100755
--- a/ovn/utilities/ovn-ctl
+++ b/ovn/utilities/ovn-ctl
@@ -95,26 +95,26 @@ promote_ovnsb() {
 
 start_ovsdb__() {
     local DB=$1 db=$2 schema_name=$3 table_name=$4
-    eval local pid=\$DB_${DB}_PID
-    eval local cluster_local_addr=\$DB_${DB}_CLUSTER_LOCAL_ADDR
-    eval local cluster_local_port=\$DB_${DB}_CLUSTER_LOCAL_PORT
-    eval local cluster_local_proto=\$DB_${DB}_CLUSTER_LOCAL_PROTO
-    eval local cluster_remote_addr=\$DB_${DB}_CLUSTER_REMOTE_ADDR
-    eval local cluster_remote_port=\$DB_${DB}_CLUSTER_REMOTE_PORT
-    eval local cluster_remote_proto=\$DB_${DB}_CLUSTER_REMOTE_PROTO
-    eval local sync_from_proto=\$DB_${DB}_SYNC_FROM_PROTO
-    eval local sync_from_addr=\$DB_${DB}_SYNC_FROM_ADDR
-    eval local sync_from_port=\$DB_${DB}_SYNC_FROM_PORT
-    eval local file=\$DB_${DB}_FILE
-    eval local schema=\$DB_${DB}_SCHEMA
-    eval local logfile=\$OVN_${DB}_LOGFILE
-    eval local log=\$OVN_${DB}_LOG
-    eval local sock=\$DB_${DB}_SOCK
-    eval local detach=\$DB_${DB}_DETACH
-    eval local create_insecure_remote=\$DB_${DB}_CREATE_INSECURE_REMOTE
-    eval local port=\$DB_${DB}_PORT
-    eval local addr=\$DB_${DB}_ADDR
-    eval local active_conf_file=\$ovn${db}_active_conf_file
+    eval pid=\$DB_${DB}_PID
+    eval cluster_local_addr=\$DB_${DB}_CLUSTER_LOCAL_ADDR
+    eval cluster_local_port=\$DB_${DB}_CLUSTER_LOCAL_PORT
+    eval cluster_local_proto=\$DB_${DB}_CLUSTER_LOCAL_PROTO
+    eval cluster_remote_addr=\$DB_${DB}_CLUSTER_REMOTE_ADDR
+    eval cluster_remote_port=\$DB_${DB}_CLUSTER_REMOTE_PORT
+    eval cluster_remote_proto=\$DB_${DB}_CLUSTER_REMOTE_PROTO
+    eval sync_from_proto=\$DB_${DB}_SYNC_FROM_PROTO
+    eval sync_from_addr=\$DB_${DB}_SYNC_FROM_ADDR
+    eval sync_from_port=\$DB_${DB}_SYNC_FROM_PORT
+    eval file=\$DB_${DB}_FILE
+    eval schema=\$DB_${DB}_SCHEMA
+    eval logfile=\$OVN_${DB}_LOGFILE
+    eval log=\$OVN_${DB}_LOG
+    eval sock=\$DB_${DB}_SOCK
+    eval detach=\$DB_${DB}_DETACH
+    eval create_insecure_remote=\$DB_${DB}_CREATE_INSECURE_REMOTE
+    eval port=\$DB_${DB}_PORT
+    eval addr=\$DB_${DB}_ADDR
+    eval active_conf_file=\$ovn${db}_active_conf_file
 
     # Check and eventually start ovsdb-server for DB
     if pidfile_is_running $pid; then
-- 
1.9.1



More information about the dev mailing list