Blob Blame History Raw
From e3c0454f83ee71eefdee54e48d51427330df892c Mon Sep 17 00:00:00 2001
From: Michele Baldessari <michele@acksyn.org>
Date: Thu, 25 Mar 2021 10:32:10 +0100
Subject: [PATCH 03/16] Fix connection string in case of changes in the
 ovndb-servers.ocf RA

Currently if you update the master_ip attribute, pacemaker will restart
the resource but the ovn master role will still listen to the previous
old ip address. The reason for this is the following piece of code:

  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}" \
      inactivity_probe=$INACTIVE_PROBE -- set NB_Global . connections=@conn_uuid
  fi

Once the connection is set the first time 'get NB_global . connections'
will always return the UUID of the connection so we're never changing
the connection data.

Let's set the connection info whenever the connection is not "[]"

Tested as follows:
1) Started with the following listening ip addresses (resource is configured with master_ip=172.17.1.44):
tcp   LISTEN 0      10        172.17.1.44:6641       0.0.0.0:*    users:(("ovsdb-server",pid=150360,fd=15)) ino:18609895 sk:4d <->
tcp   LISTEN 0      10        172.17.1.44:6642       0.0.0.0:*    users:(("ovsdb-server",pid=150379,fd=15)) ino:18609038 sk:4e <->

2) Updated the resource master_ip with:
pcs resource update ovndb_servers master_ip=4.5.6.7

3) Observed the new listening ip addresses on the master node:
[root@controller-3 stdouts]# ss -natulpe |grep 664[12]
tcp   LISTEN 0      10            4.5.6.7:6641       0.0.0.0:*    users:(("ovsdb-server",pid=516770,fd=15)) ino:11641860 sk:4d <->
tcp   LISTEN 0      10            4.5.6.7:6642       0.0.0.0:*    users:(("ovsdb-server",pid=516789,fd=15)) ino:11642885 sk:4e <->

Previously we'd observe ovsdb-server listening to the old IP even after
the resource change.

Signed-off-by: Michele Baldessari <michele@acksyn.org>
Signed-off-by: Numan Siddique <numans@ovn.org>
(cherry picked from master commit 7f8bb3f2f77567d8fb30657ad5c3a9408692d6b5)
---
 utilities/ovndb-servers.ocf | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/utilities/ovndb-servers.ocf b/utilities/ovndb-servers.ocf
index 7351c7d64..eba9c97a1 100755
--- a/utilities/ovndb-servers.ocf
+++ b/utilities/ovndb-servers.ocf
@@ -259,6 +259,9 @@ ovsdb_server_notify() {
             ovn-nbctl -- --id=@conn_uuid create Connection \
 target="p${NB_MASTER_PROTO}\:${NB_MASTER_PORT}\:${LISTEN_ON_IP}" \
 inactivity_probe=$INACTIVE_PROBE -- set NB_Global . connections=@conn_uuid
+        else
+            CONN_UID=$(sed -e 's/^\[//' -e 's/\]$//' <<< ${conn})
+            ovn-nbctl set connection "${CONN_UID}" target="p${NB_MASTER_PROTO}\:${NB_MASTER_PORT}\:${LISTEN_ON_IP}"
         fi
 
         conn=`ovn-sbctl get SB_global . connections`
@@ -267,6 +270,9 @@ inactivity_probe=$INACTIVE_PROBE -- set NB_Global . connections=@conn_uuid
             ovn-sbctl -- --id=@conn_uuid create Connection \
 target="p${SB_MASTER_PROTO}\:${SB_MASTER_PORT}\:${LISTEN_ON_IP}" \
 inactivity_probe=$INACTIVE_PROBE -- set SB_Global . connections=@conn_uuid
+        else
+            CONN_UID=$(sed -e 's/^\[//' -e 's/\]$//' <<< ${conn})
+            ovn-sbctl set connection "${CONN_UID}" target="p${SB_MASTER_PROTO}\:${SB_MASTER_PORT}\:${LISTEN_ON_IP}"
         fi
 
     else
-- 
2.29.2