When the VIP is an IPv6 address we get the following error in the
resource agent:
ovndb_servers_notify_0:355:stderr [ + ovn-sbctl -- --id=@conn_uuid create 
Connection 'target=ptcp\:6642\:[fd00:fd00:fd00:2000::a2]' 
inactivity_probe=180000 -- set SB_Global . connections=@conn_uuid ]
ovndb_servers_notify_0:355:stderr [ ovn-sbctl: 
ptcp\:6642\:[fd00:fd00:fd00:2000::a2]: unexpected "[" parsing string ]

This is because MASTER_IP is an IPv6 address and is being passed to
ovn-[ns]bctl without being escaped and the command errors out with
unexpected parsing string errors. The rest of the create Connection
command was already escaping the columns, we are just missing the ip
address bits in case of IPv6.

Let's make sure we escape the '[]:' characters and avoid this problem.
Tested this on an OpenStack environment on both IPv6 and IPv4.

Signed-off-by: Michele Baldessari <[email protected]>
---
 utilities/ovndb-servers.ocf | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/utilities/ovndb-servers.ocf b/utilities/ovndb-servers.ocf
index 56c2bc3227c3..2181bc5e273a 100755
--- a/utilities/ovndb-servers.ocf
+++ b/utilities/ovndb-servers.ocf
@@ -251,11 +251,14 @@ ovsdb_server_notify() {
         else
            LISTEN_ON_IP=${MASTER_IP}
         fi
+        # ovn-nbctl wants ':[]' characters to be escaped. We do so in order
+        # to make this work when MASTER_IP is an IPv6 address
+        LISTEN_ON_IP_ESCAPED=$(echo ${LISTEN_ON_IP} | sed -e 
's/\(\[\|\]\|:\)/\\\1/g')
         conn=`ovn-nbctl get NB_global . connections`
         if [ "$conn" == "[]" ]
         then
             ovn-nbctl -- --id=@conn_uuid create Connection \
-target="p${NB_MASTER_PROTO}\:${NB_MASTER_PORT}\:${LISTEN_ON_IP}" \
+target="p${NB_MASTER_PROTO}\:${NB_MASTER_PORT}\:${LISTEN_ON_IP_ESCAPED}" \
 inactivity_probe=$INACTIVE_PROBE -- set NB_Global . connections=@conn_uuid
         fi
 
@@ -263,7 +266,7 @@ inactivity_probe=$INACTIVE_PROBE -- set NB_Global . 
connections=@conn_uuid
         if [ "$conn" == "[]" ]
         then
             ovn-sbctl -- --id=@conn_uuid create Connection \
-target="p${SB_MASTER_PROTO}\:${SB_MASTER_PORT}\:${LISTEN_ON_IP}" \
+target="p${SB_MASTER_PROTO}\:${SB_MASTER_PORT}\:${LISTEN_ON_IP_ESCAPED}" \
 inactivity_probe=$INACTIVE_PROBE -- set SB_Global . connections=@conn_uuid
         fi
 
-- 
2.26.2

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to