Skip to content

Commit

Permalink
controller: Handle postponed ports release.
Browse files Browse the repository at this point in the history
Reported-at: https://mail.openvswitch.org/pipermail/ovs-dev/2023-May/405107.html
Suggested-by: Priyankar Jain <priyankar.jain@nutanix.com>

Signed-off-by: Xavier Simonart <xsimonar@redhat.com>
Signed-off-by: Numan Siddique <numans@ovn.org>
  • Loading branch information
simonartxavier authored and numansiddique committed Jun 12, 2024
1 parent d4c566d commit e5d187b
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 1 deletion.
10 changes: 9 additions & 1 deletion controller/binding.c
Original file line number Diff line number Diff line change
Expand Up @@ -1317,6 +1317,12 @@ lport_maybe_postpone(const char *port_name, long long int now,
return true;
}

static bool
is_postponed_port(const char *port_name)
{
return sset_contains(&_postponed_ports, port_name);
}

/* Returns false if lport is not claimed due to 'sb_readonly'.
* Returns true otherwise.
*/
Expand Down Expand Up @@ -1491,7 +1497,8 @@ is_binding_lport_this_chassis(struct binding_lport *b_lport,
{
return (b_lport && b_lport->pb && chassis &&
(b_lport->pb->chassis == chassis
|| is_additional_chassis(b_lport->pb, chassis)));
|| is_additional_chassis(b_lport->pb, chassis)
|| is_postponed_port(b_lport->pb->logical_port)));
}

/* Returns 'true' if the 'lbinding' has binding lports of type LP_CONTAINER,
Expand Down Expand Up @@ -1593,6 +1600,7 @@ consider_vif_lport_(const struct sbrec_port_binding *pb,
}

if (!lbinding_set || !can_bind) {
remove_related_lport(pb, b_ctx_out);
return release_lport(pb, b_ctx_in->chassis_rec,
!b_ctx_in->ovnsb_idl_txn,
b_ctx_out->tracked_dp_bindings,
Expand Down
55 changes: 55 additions & 0 deletions tests/ovn.at
Original file line number Diff line number Diff line change
Expand Up @@ -38374,3 +38374,58 @@ OVN_CLEANUP([hv1])
AT_CLEANUP
])

OVN_FOR_EACH_NORTHD([
AT_SETUP([Deleting vif while controller fight for port claim])
ovn_start

ovn-nbctl ls-add ls0
ovn-nbctl lsp-add ls0 lsp0
ovn-nbctl lsp-add ls0 lsp1

net_add n1
for i in 1 2; do
sim_add hv$i
as hv$i
ovs-vsctl add-br br-phys
ovn_attach n1 br-phys 192.168.0.$i
done

check ovn-nbctl --wait=hv sync
hv1_uuid=$(ovn-sbctl --bare --columns _uuid list chassis hv1)
hv2_uuid=$(ovn-sbctl --bare --columns _uuid list chassis hv2)

as hv1 ovs-vsctl -- add-port br-int vif1 -- set Interface vif1 external-ids:iface-id=lsp1
as hv1 ovs-vsctl -- add-port br-int vif -- set Interface vif external-ids:iface-id=lsp0
wait_for_ports_up

# Delete vif => store flows w/ only vif1, and no vif
as hv1 ovs-vsctl -- del-port br-int vif
check ovn-nbctl --wait=hv sync
DUMP_FLOWS([hv1], [oflows1])
sleep_controller hv1
as hv2 ovs-vsctl -- add-port br-int vif -- set Interface vif external-ids:iface-id=lsp0
as hv1 ovs-vsctl -- add-port br-int vif -- set Interface vif external-ids:iface-id=lsp0

OVS_WAIT_UNTIL([
chassis=$(ovn-sbctl --bare --columns chassis list port_binding lsp0)
test "$chassis" = $hv2_uuid
])

sleep_sb
wake_up_controller hv1
sleep_controller hv2

as hv1 ovs-vsctl -- del-port br-int vif
wake_up_sb
wake_up_controller hv2

as hv2 ovs-vsctl -- del-port br-int vif
check ovn-nbctl --wait=hv sync

DUMP_FLOWS([hv1], [oflows2])

check diff oflows1 oflows2
OVN_CLEANUP([hv1],[hv2])

AT_CLEANUP
])

0 comments on commit e5d187b

Please sign in to comment.