diff mbox series

[ovs-dev,v2] ovn-ic: Handle NB:name updates properly.

Message ID 20240123134050.907608-1-mheib@redhat.com
State Accepted
Headers show
Series [ovs-dev,v2] ovn-ic: Handle NB:name updates properly. | expand

Checks

Context Check Description
ovsrobot/apply-robot success apply and check: success
ovsrobot/github-robot-_Build_and_Test success github build: passed
ovsrobot/github-robot-_ovn-kubernetes success github build: passed

Commit Message

Mohammad Heib Jan. 23, 2024, 1:40 p.m. UTC
When the user updates the NB_GLOBAL.name after registering
to IC Databases if the user already has defined chassis as a gateway
that will cause ovn-ic instance to run in an infinity loop trying
to update the gateways and insert the current gateway to the SB.chassis
tables as a remote chassis (we match on the new AZ ) which will fail since
we already have this chassis with is-interconn in local SB.

This patch aims to fix the above issues by updating the AZ.name only
when the user updates the NB.name locally.

Signed-off-by: Mohammad Heib <mheib@redhat.com>
Acked-by: Dumitru Ceara <dceara@redhat.com>
---
 ic/ovn-ic.c     | 10 +++++++---
 tests/ovn-ic.at | 24 ++++++++++++++++++++++++
 2 files changed, 31 insertions(+), 3 deletions(-)

Comments

Dumitru Ceara Jan. 30, 2024, 11:36 a.m. UTC | #1
On 1/23/24 14:40, Mohammad Heib wrote:
> When the user updates the NB_GLOBAL.name after registering
> to IC Databases if the user already has defined chassis as a gateway
> that will cause ovn-ic instance to run in an infinity loop trying
> to update the gateways and insert the current gateway to the SB.chassis
> tables as a remote chassis (we match on the new AZ ) which will fail since
> we already have this chassis with is-interconn in local SB.
> 
> This patch aims to fix the above issues by updating the AZ.name only
> when the user updates the NB.name locally.
> 
> Signed-off-by: Mohammad Heib <mheib@redhat.com>
> Acked-by: Dumitru Ceara <dceara@redhat.com>
> ---

Thanks, Mohammad!  I changed my ack to a signed-off-by and pushed this
to main and backported it to all stable branches down to 22.03.

Regards,
Dumitru
diff mbox series

Patch

diff --git a/ic/ovn-ic.c b/ic/ovn-ic.c
index 8ceb34d7c..12e2729ce 100644
--- a/ic/ovn-ic.c
+++ b/ic/ovn-ic.c
@@ -132,14 +132,18 @@  az_run(struct ic_context *ctx)
         return NULL;
     }
 
-    /* Delete old AZ if name changes.  Note: if name changed when ovn-ic
-     * is not running, one has to manually delete the old AZ with:
+    /* Update old AZ if name changes.  Note: if name changed when ovn-ic
+     * is not running, one has to manually delete/update the old AZ with:
      * "ovn-ic-sbctl destroy avail <az>". */
     static char *az_name;
     const struct icsbrec_availability_zone *az;
     if (az_name && strcmp(az_name, nb_global->name)) {
         ICSBREC_AVAILABILITY_ZONE_FOR_EACH (az, ctx->ovnisb_idl) {
-            if (!strcmp(az->name, az_name)) {
+            /* AZ name update locally need to update az in ISB. */
+            if (nb_global->name[0] && !strcmp(az->name, az_name)) {
+                icsbrec_availability_zone_set_name(az, nb_global->name);
+                break;
+            } else if (!nb_global->name[0] && !strcmp(az->name, az_name)) {
                 icsbrec_availability_zone_delete(az);
                 break;
             }
diff --git a/tests/ovn-ic.at b/tests/ovn-ic.at
index d4c436f84..6061d054c 100644
--- a/tests/ovn-ic.at
+++ b/tests/ovn-ic.at
@@ -28,7 +28,31 @@  availability-zone az3
 ])
 
 OVN_CLEANUP_IC([az1], [az2])
+AT_CLEANUP
+])
+
+
+OVN_FOR_EACH_NORTHD([
+AT_SETUP([ovn-ic -- AZ update in GW])
+ovn_init_ic_db
+net_add n1
 
+ovn_start az1
+sim_add gw-az1
+as gw-az1
+
+check ovs-vsctl add-br br-phys
+ovn_az_attach az1 n1 br-phys 192.168.1.1
+check ovs-vsctl set open . external-ids:ovn-is-interconn=true
+
+az_uuid=$(fetch_column ic-sb:availability-zone _uuid name="az1")
+ovn_as az1 ovn-nbctl set NB_Global . name="az2"
+wait_column "$az_uuid" ic-sb:availability-zone _uuid name="az2"
+
+# make sure that gateway still point to the same AZ with new name
+wait_column "$az_uuid" ic-sb:gateway availability_zone name="gw-az1"
+
+OVN_CLEANUP_IC([az1])
 AT_CLEANUP
 ])