Skip to content

Commit 5ae42c8

Browse files
committed
northd: Fix port group I-P for recreated groups.
When northd handles in a single iteration the following transactions: A. port group deletion (e.g., name="pg") B. port group addition (same name as the deleted group, i.e., "pg" but with a new UUID) with a logical switch port. it should correctly reconcile the SB contents, the resulting SB port group contents should include the "recreated" group too. That wasn't the case because the deleted name was added to the stale_sb_port_groups set and not removed from it when processing the new group record. Also, make sure we first process all deletions and then all updates (and additions) in order to avoid pruning issues. Fixes: a1d82e9 ("northd: Process port_group changes incrementally.") Reported-at: https://redhat.atlassian.net/browse/FDP-3966 Acked-by: Ales Musil <amusil@redhat.com> Signed-off-by: Dumitru Ceara <dceara@redhat.com>
1 parent 1e5fe58 commit 5ae42c8

2 files changed

Lines changed: 49 additions & 0 deletions

File tree

northd/en-port-group.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,15 +558,34 @@ port_group_nb_port_group_handler(struct engine_node *node, void *data_)
558558
HMAPX_INITIALIZER(&updated_ls_port_groups);
559559

560560
struct sset stale_sb_port_groups = SSET_INITIALIZER(&stale_sb_port_groups);
561+
/* Process all deletions first. */
561562
NBREC_PORT_GROUP_TABLE_FOR_EACH_TRACKED (nb_pg, nb_pg_table) {
563+
if (!nbrec_port_group_is_deleted(nb_pg)) {
564+
continue;
565+
}
566+
562567
ls_port_group_process(&data->ls_port_groups,
563568
&data->port_groups_lses,
564569
&data->ls_port_groups_sets_changed,
565570
input_data.ls_ports,
566571
nb_pg, &updated_ls_port_groups,
567572
&stale_sb_port_groups);
573+
}
574+
575+
/* Then process all additions/updates. */
576+
NBREC_PORT_GROUP_TABLE_FOR_EACH_TRACKED (nb_pg, nb_pg_table) {
577+
if (nbrec_port_group_is_deleted(nb_pg)) {
578+
continue;
568579
}
569580

581+
ls_port_group_process(&data->ls_port_groups,
582+
&data->port_groups_lses,
583+
&data->ls_port_groups_sets_changed,
584+
input_data.ls_ports,
585+
nb_pg, &updated_ls_port_groups,
586+
&stale_sb_port_groups);
587+
}
588+
570589
/* Changes have been successfully processed incrementally now update
571590
* the SB too. */
572591
struct ovsdb_idl_index *sbrec_port_group_by_name =
@@ -598,6 +617,7 @@ port_group_nb_port_group_handler(struct engine_node *node, void *data_)
598617
sorted_array_from_sset(&ls_pg_rec->ports);
599618
update_sb_port_group(&nb_ports, sb_pg);
600619
sorted_array_destroy(&nb_ports);
620+
sset_find_and_delete(&stale_sb_port_groups, sb_pg_name_cstr);
601621
}
602622
}
603623
ds_destroy(&sb_pg_name);

tests/ovn-northd.at

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11023,6 +11023,35 @@ OVN_CLEANUP_NORTHD
1102311023
AT_CLEANUP
1102411024
])
1102511025

11026+
OVN_FOR_EACH_NORTHD_NO_HV([
11027+
AT_SETUP([Port Group recreation incremental processing])
11028+
AT_KEYWORDS([incremental processing])
11029+
ovn_start
11030+
11031+
check ovn-nbctl ls-add ls -- lsp-add ls lsp
11032+
check ovn-nbctl --wait=sb pg-add pg lsp
11033+
11034+
ls_key=$(fetch_column Datapath_Binding tunnel_key external_ids:name=ls)
11035+
check_column "lsp" sb:Port_Group ports name="${ls_key}_pg"
11036+
11037+
dnl Simulate northd handling a batch of transactions that recreate the
11038+
dnl port group.
11039+
check as northd ovn-appctl -t ovn-northd inc-engine/clear-stats
11040+
sleep_northd
11041+
check ovn-nbctl pg-del pg
11042+
check ovn-nbctl pg-add pg lsp
11043+
wake_up_northd
11044+
11045+
check ovn-nbctl --wait=sb sync
11046+
check_engine_stats northd norecompute compute
11047+
check_engine_stats port_group norecompute compute
11048+
check_engine_stats lflow norecompute compute
11049+
check_column "lsp" sb:Port_Group ports name="${ls_key}_pg"
11050+
11051+
OVN_CLEANUP_NORTHD
11052+
AT_CLEANUP
11053+
])
11054+
1102611055
OVN_FOR_EACH_NORTHD([
1102711056
AT_SETUP([Check default drop])
1102811057
AT_KEYWORDS([drop])

0 commit comments

Comments
 (0)