[ovs-dev] [PATCH ovn v2] Make the notify() calls work with IPv6 in the OCF resource-agent

Michele Baldessari michele at acksyn.org
Wed Jun 3 12:43:47 UTC 2020


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 <michele at acksyn.org>
---
 utilities/ovndb-servers.ocf | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/utilities/ovndb-servers.ocf b/utilities/ovndb-servers.ocf
index 56c2bc3227c3..354818a78d4d 100755
--- a/utilities/ovndb-servers.ocf
+++ b/utilities/ovndb-servers.ocf
@@ -249,7 +249,9 @@ ovsdb_server_notify() {
         if [ "x${LISTEN_ON_MASTER_IP_ONLY}" = xno ]; then
            LISTEN_ON_IP="0.0.0.0"
         else
-           LISTEN_ON_IP=${MASTER_IP}
+           # ovn-[sn]bctl want ':[]' characters to be escaped. We do so in order
+           # to make this work when MASTER_IP is an IPv6 address
+           LISTEN_ON_IP=$(sed -e 's/\(\[\|\]\|:\)/\\\1/g' <<< ${MASTER_IP})
         fi
         conn=`ovn-nbctl get NB_global . connections`
         if [ "$conn" == "[]" ]
-- 
2.26.2



More information about the dev mailing list