Skip to content

Commit

Permalink
northd: Fix ha_chassis_group txn error for external ports.
Browse files Browse the repository at this point in the history
If an external logical port 'sw0-p1' is associated with an
ha_chassis_group and later CMS runs a command to clear the
ha_chassis_group and set the type to normal in the same
transaction, i.e

ovn-nbctl clear logical_switch_port sw0-p1 ha_chassis_group -- \
set logical_switch_port sw0-p1 'type=""'

then, ovn-northd goes into a continous loop trying to delete the
ha_chassis_group in SB DB .  ovn-northd doesn't clear the
ha_chassis_group of the port binding sw0-p1 in the SB DB and
hence the constraint violation is seen.

This issue is seen when lport sw0-p1 is the only one referencing
the ha_chassis_group in SB DB.  This patch fixes this issue.

Reported-at: https://bugzilla.redhat.com/show_bug.cgi?id=1927369
Reported-by: Jakub Libosvar <jlibosva@redhat.com>
Acked-by: Mark Michelson <mmichels@redhat.com>
Signed-off-by: Numan Siddique <numans@ovn.org>
  • Loading branch information
numansiddique committed Feb 19, 2021
1 parent c6e21a2 commit f1f0de2
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 3 deletions.
6 changes: 6 additions & 0 deletions northd/ovn-northd.c
Expand Up @@ -2991,6 +2991,12 @@ ovn_port_update_sbrec(struct northd_context *ctx,
} else {
sbrec_port_binding_set_ha_chassis_group(op->sb, NULL);
}
} else if (op->sb->ha_chassis_group) {
/* Clear the port bindings ha_chassis_group if the type is
* not external and if this column is set. This can happen
* when an external port is reset to type normal and
* ha_chassis_group cleared in the same transaction. */
sbrec_port_binding_set_ha_chassis_group(op->sb, NULL);
}
} else {
const char *chassis = NULL;
Expand Down
47 changes: 44 additions & 3 deletions tests/ovn-northd.at
Expand Up @@ -605,11 +605,12 @@ wait_row_count Port_Binding 0 logical_port=sw0-pext1 'chassis!=[[]]'
wait_row_count HA_Chassis_Group 1 name=hagrp1
wait_row_count HA_Chassis 3

# Clear ha_chassis_group for sw0-pext2
ovn-nbctl --wait=sb clear logical_switch_port sw0-pext2 ha_chassis_group
AS_BOX([Clear ha_chassis_group for sw0-pext2 and reset port type to normal in the same txn])

wait_row_count Port_Binding 0 logical_port=sw0-pext2 'chassis!=[[]]'
check ovn-nbctl --wait=sb clear logical_switch_port sw0-pext2 \
ha_chassis_group -- set logical_switch_port sw0-pext2 'type=""'
wait_row_count HA_Chassis_Group 0
wait_row_count Port_Binding 0 logical_port=sw0-pext2 'chassis!=[[]]'
check_row_count HA_Chassis 0

as ovn-sb
Expand Down Expand Up @@ -2599,3 +2600,43 @@ AT_CHECK([grep "lr_out_snat" lr0flows | grep force_snat_for_lb | sort], [0], [dn
])

AT_CLEANUP

AT_SETUP([ovn -- HA chassis group cleanup for external port ])
ovn_start

check ovn-nbctl ls-add sw0
check ovn-nbctl lsp-add sw0 sw0-p1
check ovn-nbctl lsp-set-type sw0-p1 external

check ovn-sbctl chassis-add ch1 geneve 127.0.0.1
check ovn-sbctl chassis-add ch2 geneve 127.0.0.2

check ovn-nbctl ha-chassis-group-add hagrp1
check ovn-nbctl ha-chassis-group-add-chassis hagrp1 ch1 20
check ovn-nbctl --wait=sb ha-chassis-group-add-chassis hagrp1 ch2 10

ha_grp1_uuid=$(fetch_column nb:ha_chassis_group _uuid)
echo "ha grp1 uuid = $ha_grp1_uuid"
ovn-nbctl list ha_chassis_group
check ovn-nbctl set logical_switch_port sw0-p1 ha_chassis_group=$ha_grp1_uuid

wait_row_count ha_chassis_group 1
check ovn-nbctl clear logical_switch_port sw0-p1 ha_chassis_group
wait_row_count ha_chassis_group 0

check ovn-nbctl set logical_switch_port sw0-p1 ha_chassis_group=$ha_grp1_uuid
wait_row_count ha_chassis_group 1
sb_ha_grp1_uuid=$(fetch_column ha_chassis_group _uuid)

echo
echo "__file__:__line__:Check that port_binding sw0-p1 has ha_chassis_group set"

check_column "$sb_ha_grp1_uuid" Port_Binding ha_chassis_group logical_port=sw0-p1

AS_BOX([Clear ha_chassis_group for sw0-p1 and reset port type to normal port in the same txn])

check ovn-nbctl clear logical_switch_port sw0-p1 ha_chassis_group -- set logical_switch_port sw0-p1 'type=""'
wait_row_count ha_chassis_group 0
check_column "" Port_Binding chassis logical_port=sw0-p1

AT_CLEANUP

0 comments on commit f1f0de2

Please sign in to comment.