Message ID | 20240827134641.3140022-2-xsimonar@redhat.com |
---|---|
State | New |
Headers | show |
Series | ct_zones allocations. | expand |
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 | fail | github build: failed |
Thanks Xavier, it looks good to me. Acked-by: Mark Michelson <mmichels@redhat.com> On 8/27/24 09:46, Xavier Simonart wrote: > In ct_zones I+P, when ports changed to patch ports (e.g. from l3gateway, > for which ct_zone has been allocated), delete the ct_zone. > > Signed-off-by: Xavier Simonart <xsimonar@redhat.com> > --- > controller/binding.c | 10 +++ > controller/ovn-controller.c | 9 ++- > tests/ovn.at | 142 ++++++++++++++++++++++++++++++++++++ > 3 files changed, 160 insertions(+), 1 deletion(-) > > diff --git a/controller/binding.c b/controller/binding.c > index bfdeb99b9..d3fe127f7 100644 > --- a/controller/binding.c > +++ b/controller/binding.c > @@ -2934,6 +2934,16 @@ consider_patch_port_for_local_datapaths(const struct sbrec_port_binding *pb, > b_ctx_out->tracked_dp_bindings); > } > } > + > + if (sbrec_port_binding_is_updated(pb, SBREC_PORT_BINDING_COL_TYPE) && > + (pb->chassis == b_ctx_in->chassis_rec || > + is_additional_chassis(pb, b_ctx_in->chassis_rec))) { > + remove_local_lports(pb->logical_port, b_ctx_out); > + release_lport(pb, b_ctx_in->chassis_rec, > + !b_ctx_in->ovnsb_idl_txn, > + b_ctx_out->tracked_dp_bindings, > + b_ctx_out->if_mgr); > + } > } > > static bool > diff --git a/controller/ovn-controller.c b/controller/ovn-controller.c > index 854d80bdf..a10f1af8a 100644 > --- a/controller/ovn-controller.c > +++ b/controller/ovn-controller.c > @@ -2312,9 +2312,16 @@ ct_zones_runtime_data_handler(struct engine_node *node, void *data) > && strcmp(t_lport->pb->type, "localnet")) { > /* We allocate zone-id's only to VIF, localport, l3gateway, > * and localnet lports. */ > + if (sbrec_port_binding_is_updated(t_lport->pb, > + SBREC_PORT_BINDING_COL_TYPE)) { > + updated |= ct_zone_handle_port_update(&ct_zones_data->ctx, > + t_lport->pb, > + false, &scan_start, > + min_ct_zone, max_ct_zone); > + } > + > continue; > } > - > bool port_updated = > t_lport->tracked_type == TRACKED_RESOURCE_NEW || > t_lport->tracked_type == TRACKED_RESOURCE_UPDATED; > diff --git a/tests/ovn.at b/tests/ovn.at > index 50c9f04da..4d9beea1b 100644 > --- a/tests/ovn.at > +++ b/tests/ovn.at > @@ -38924,3 +38924,145 @@ OVN_CHECK_PACKETS([hv/vif1-tx.pcap], [expected-vif1]) > > AT_CLEANUP > ]) > + > +OVN_FOR_EACH_NORTHD([ > +AT_SETUP([ct_zones]) > +AT_KEYWORDS([ct_zones]) > + > +ovn_start > + > +net_add n1 > +for i in 1 2; do > + check ovn-nbctl ls-add ls${i} > + ovn-nbctl lsp-add ls${i} lsp${i} > + sim_add hv$i > + as hv$i > + ovs-vsctl add-br br-phys > + ovn_attach n1 br-phys 192.168.0.$i > + ovs-vsctl -- add-port br-int vif${i} -- set Interface vif${i} external-ids:iface-id=lsp${i} > +done > + > +check ovn-nbctl lr-add r1 > +check ovn-nbctl lrp-add r1 r1-ls1 f0:00:00:00:00:01 192.168.2.1/24 \ > + -- lsp-add ls1 ls1-r1 \ > + -- set Logical_Switch_Port ls1-r1 type=router options:router-port=r1-ls1 addresses=router > + > +check ovn-nbctl lrp-add r1 r1-ls2 f0:00:00:00:00:02 192.168.3.1/24 \ > + -- lsp-add ls2 ls2-r1 \ > + -- set Logical_Switch_Port ls2-r1 type=router options:router-port=r1-ls2 addresses=router > + > +check ovn-nbctl --wait=hv sync > + > +AS_BOX([With patch ports]) > +zone_list_hv1=$(as hv1 ovn-appctl -t ovn-controller ct-zone-list | sort) > +AT_CHECK([echo "$zone_list_hv1" | sed "s/ [[0-9]]*/ ??/" | sort], [0], [dnl > +ls1_dnat ?? > +ls1_snat ?? > +ls2_dnat ?? > +ls2_snat ?? > +lsp1 ?? > +r1_dnat ?? > +r1_snat ?? > +]) > + > +zone_list_hv2=$(as hv2 ovn-appctl -t ovn-controller ct-zone-list | sort) > +AT_CHECK([echo "$zone_list_hv2" | sed "s/ [[0-9]]*/ ??/" | sort], [0], [dnl > +ls1_dnat ?? > +ls1_snat ?? > +ls2_dnat ?? > +ls2_snat ?? > +lsp2 ?? > +r1_dnat ?? > +r1_snat ?? > +]) > + > +AS_BOX([With patch ports after recompute]) > +check as hv1 ovn-appctl -t ovn-controller inc-engine/recompute > +check as hv2 ovn-appctl -t ovn-controller inc-engine/recompute > +zone_list_hv1_after_recompute=$(as hv1 ovn-appctl -t ovn-controller ct-zone-list | sort) > +zone_list_hv2_after_recompute=$(as hv2 ovn-appctl -t ovn-controller ct-zone-list | sort) > +AT_CHECK([test "X$zone_list_hv1" = "X$zone_list_hv1_after_recompute"]) > +AT_CHECK([test "X$zone_list_hv2" = "X$zone_list_hv2_after_recompute"]) > + > +AS_BOX([With l3gw in hv2]) > +check ovn-nbctl --wait=hv set Logical_Router r1 options:chassis=hv2 > +# ls2 should now only be a local datapath in hv2. > +# However, ovn-controller does not remove datapath from list of ldp when needed, so ls2 is still seen as local in hv1. > +zone_list_hv1=$(as hv1 ovn-appctl -t ovn-controller ct-zone-list | sort) > +AT_CHECK([echo "$zone_list_hv1" | sed "s/ [[0-9]]*/ ??/" | sort], [0], [dnl > +ls1_dnat ?? > +ls1_snat ?? > +ls2_dnat ?? > +ls2_snat ?? > +lsp1 ?? > +r1_dnat ?? > +r1_snat ?? > +]) > + > +# l3gw ports should have ct_zones allocated > +zone_list_hv2=$(as hv2 ovn-appctl -t ovn-controller ct-zone-list | sort) > +AT_CHECK([echo "$zone_list_hv2" | sed "s/ [[0-9]]*/ ??/" | sort], [0], [dnl > +ls1-r1 ?? > +ls1_dnat ?? > +ls1_snat ?? > +ls2-r1 ?? > +ls2_dnat ?? > +ls2_snat ?? > +lsp2 ?? > +r1-ls1 ?? > +r1-ls2 ?? > +r1_dnat ?? > +r1_snat ?? > +]) > + > +AS_BOX([With l3gw ports after recompute]) > +check as hv1 ovn-appctl -t ovn-controller inc-engine/recompute > +check as hv2 ovn-appctl -t ovn-controller inc-engine/recompute > + > +# ls2 not in hv1 after recompute, as expected > +zone_list_hv1_after_recompute=$(as hv1 ovn-appctl -t ovn-controller ct-zone-list | sort) > +AT_CHECK([echo "$zone_list_hv1_after_recompute" | sed "s/ [[0-9]]*/ ??/" | sort], [0], [dnl > +ls1_dnat ?? > +ls1_snat ?? > +lsp1 ?? > +]) > + > +zone_list_hv2_after_recompute=$(as hv2 ovn-appctl -t ovn-controller ct-zone-list | sort) > +AT_CHECK([test "X$zone_list_hv2" = "X$zone_list_hv2_after_recompute"]) > + > +AS_BOX([With patch ports again]) > +check ovn-nbctl --wait=hv remove Logical_Router r1 options chassis=hv2 > +zone_list_hv1=$(as hv1 ovn-appctl -t ovn-controller ct-zone-list | sort) > +AT_CHECK([echo "$zone_list_hv1" | sed "s/ [[0-9]]*/ ??/" | sort], [0], [dnl > +ls1_dnat ?? > +ls1_snat ?? > +ls2_dnat ?? > +ls2_snat ?? > +lsp1 ?? > +r1_dnat ?? > +r1_snat ?? > +]) > + > +zone_list_hv2=$(as hv2 ovn-appctl -t ovn-controller ct-zone-list | sort) > +AT_CHECK([echo "$zone_list_hv2" | sed "s/ [[0-9]]*/ ??/" | sort], [0], [dnl > +ls1_dnat ?? > +ls1_snat ?? > +ls2_dnat ?? > +ls2_snat ?? > +lsp2 ?? > +r1_dnat ?? > +r1_snat ?? > +]) > + > +check as hv1 ovn-appctl -t ovn-controller inc-engine/recompute > +check as hv2 ovn-appctl -t ovn-controller inc-engine/recompute > +AS_BOX([With patch ports after recompute]) > +zone_list_hv1_after_recompute=$(as hv1 ovn-appctl -t ovn-controller ct-zone-list | sort) > +zone_list_hv2_after_recompute=$(as hv2 ovn-appctl -t ovn-controller ct-zone-list | sort) > +AT_CHECK([test "X$zone_list_hv1" = "X$zone_list_hv1_after_recompute"]) > +AT_CHECK([test "X$zone_list_hv2" = "X$zone_list_hv2_after_recompute"]) > + > +OVN_CLEANUP([hv1],[hv2]) > + > +AT_CLEANUP > +])
diff --git a/controller/binding.c b/controller/binding.c index bfdeb99b9..d3fe127f7 100644 --- a/controller/binding.c +++ b/controller/binding.c @@ -2934,6 +2934,16 @@ consider_patch_port_for_local_datapaths(const struct sbrec_port_binding *pb, b_ctx_out->tracked_dp_bindings); } } + + if (sbrec_port_binding_is_updated(pb, SBREC_PORT_BINDING_COL_TYPE) && + (pb->chassis == b_ctx_in->chassis_rec || + is_additional_chassis(pb, b_ctx_in->chassis_rec))) { + remove_local_lports(pb->logical_port, b_ctx_out); + release_lport(pb, b_ctx_in->chassis_rec, + !b_ctx_in->ovnsb_idl_txn, + b_ctx_out->tracked_dp_bindings, + b_ctx_out->if_mgr); + } } static bool diff --git a/controller/ovn-controller.c b/controller/ovn-controller.c index 854d80bdf..a10f1af8a 100644 --- a/controller/ovn-controller.c +++ b/controller/ovn-controller.c @@ -2312,9 +2312,16 @@ ct_zones_runtime_data_handler(struct engine_node *node, void *data) && strcmp(t_lport->pb->type, "localnet")) { /* We allocate zone-id's only to VIF, localport, l3gateway, * and localnet lports. */ + if (sbrec_port_binding_is_updated(t_lport->pb, + SBREC_PORT_BINDING_COL_TYPE)) { + updated |= ct_zone_handle_port_update(&ct_zones_data->ctx, + t_lport->pb, + false, &scan_start, + min_ct_zone, max_ct_zone); + } + continue; } - bool port_updated = t_lport->tracked_type == TRACKED_RESOURCE_NEW || t_lport->tracked_type == TRACKED_RESOURCE_UPDATED; diff --git a/tests/ovn.at b/tests/ovn.at index 50c9f04da..4d9beea1b 100644 --- a/tests/ovn.at +++ b/tests/ovn.at @@ -38924,3 +38924,145 @@ OVN_CHECK_PACKETS([hv/vif1-tx.pcap], [expected-vif1]) AT_CLEANUP ]) + +OVN_FOR_EACH_NORTHD([ +AT_SETUP([ct_zones]) +AT_KEYWORDS([ct_zones]) + +ovn_start + +net_add n1 +for i in 1 2; do + check ovn-nbctl ls-add ls${i} + ovn-nbctl lsp-add ls${i} lsp${i} + sim_add hv$i + as hv$i + ovs-vsctl add-br br-phys + ovn_attach n1 br-phys 192.168.0.$i + ovs-vsctl -- add-port br-int vif${i} -- set Interface vif${i} external-ids:iface-id=lsp${i} +done + +check ovn-nbctl lr-add r1 +check ovn-nbctl lrp-add r1 r1-ls1 f0:00:00:00:00:01 192.168.2.1/24 \ + -- lsp-add ls1 ls1-r1 \ + -- set Logical_Switch_Port ls1-r1 type=router options:router-port=r1-ls1 addresses=router + +check ovn-nbctl lrp-add r1 r1-ls2 f0:00:00:00:00:02 192.168.3.1/24 \ + -- lsp-add ls2 ls2-r1 \ + -- set Logical_Switch_Port ls2-r1 type=router options:router-port=r1-ls2 addresses=router + +check ovn-nbctl --wait=hv sync + +AS_BOX([With patch ports]) +zone_list_hv1=$(as hv1 ovn-appctl -t ovn-controller ct-zone-list | sort) +AT_CHECK([echo "$zone_list_hv1" | sed "s/ [[0-9]]*/ ??/" | sort], [0], [dnl +ls1_dnat ?? +ls1_snat ?? +ls2_dnat ?? +ls2_snat ?? +lsp1 ?? +r1_dnat ?? +r1_snat ?? +]) + +zone_list_hv2=$(as hv2 ovn-appctl -t ovn-controller ct-zone-list | sort) +AT_CHECK([echo "$zone_list_hv2" | sed "s/ [[0-9]]*/ ??/" | sort], [0], [dnl +ls1_dnat ?? +ls1_snat ?? +ls2_dnat ?? +ls2_snat ?? +lsp2 ?? +r1_dnat ?? +r1_snat ?? +]) + +AS_BOX([With patch ports after recompute]) +check as hv1 ovn-appctl -t ovn-controller inc-engine/recompute +check as hv2 ovn-appctl -t ovn-controller inc-engine/recompute +zone_list_hv1_after_recompute=$(as hv1 ovn-appctl -t ovn-controller ct-zone-list | sort) +zone_list_hv2_after_recompute=$(as hv2 ovn-appctl -t ovn-controller ct-zone-list | sort) +AT_CHECK([test "X$zone_list_hv1" = "X$zone_list_hv1_after_recompute"]) +AT_CHECK([test "X$zone_list_hv2" = "X$zone_list_hv2_after_recompute"]) + +AS_BOX([With l3gw in hv2]) +check ovn-nbctl --wait=hv set Logical_Router r1 options:chassis=hv2 +# ls2 should now only be a local datapath in hv2. +# However, ovn-controller does not remove datapath from list of ldp when needed, so ls2 is still seen as local in hv1. +zone_list_hv1=$(as hv1 ovn-appctl -t ovn-controller ct-zone-list | sort) +AT_CHECK([echo "$zone_list_hv1" | sed "s/ [[0-9]]*/ ??/" | sort], [0], [dnl +ls1_dnat ?? +ls1_snat ?? +ls2_dnat ?? +ls2_snat ?? +lsp1 ?? +r1_dnat ?? +r1_snat ?? +]) + +# l3gw ports should have ct_zones allocated +zone_list_hv2=$(as hv2 ovn-appctl -t ovn-controller ct-zone-list | sort) +AT_CHECK([echo "$zone_list_hv2" | sed "s/ [[0-9]]*/ ??/" | sort], [0], [dnl +ls1-r1 ?? +ls1_dnat ?? +ls1_snat ?? +ls2-r1 ?? +ls2_dnat ?? +ls2_snat ?? +lsp2 ?? +r1-ls1 ?? +r1-ls2 ?? +r1_dnat ?? +r1_snat ?? +]) + +AS_BOX([With l3gw ports after recompute]) +check as hv1 ovn-appctl -t ovn-controller inc-engine/recompute +check as hv2 ovn-appctl -t ovn-controller inc-engine/recompute + +# ls2 not in hv1 after recompute, as expected +zone_list_hv1_after_recompute=$(as hv1 ovn-appctl -t ovn-controller ct-zone-list | sort) +AT_CHECK([echo "$zone_list_hv1_after_recompute" | sed "s/ [[0-9]]*/ ??/" | sort], [0], [dnl +ls1_dnat ?? +ls1_snat ?? +lsp1 ?? +]) + +zone_list_hv2_after_recompute=$(as hv2 ovn-appctl -t ovn-controller ct-zone-list | sort) +AT_CHECK([test "X$zone_list_hv2" = "X$zone_list_hv2_after_recompute"]) + +AS_BOX([With patch ports again]) +check ovn-nbctl --wait=hv remove Logical_Router r1 options chassis=hv2 +zone_list_hv1=$(as hv1 ovn-appctl -t ovn-controller ct-zone-list | sort) +AT_CHECK([echo "$zone_list_hv1" | sed "s/ [[0-9]]*/ ??/" | sort], [0], [dnl +ls1_dnat ?? +ls1_snat ?? +ls2_dnat ?? +ls2_snat ?? +lsp1 ?? +r1_dnat ?? +r1_snat ?? +]) + +zone_list_hv2=$(as hv2 ovn-appctl -t ovn-controller ct-zone-list | sort) +AT_CHECK([echo "$zone_list_hv2" | sed "s/ [[0-9]]*/ ??/" | sort], [0], [dnl +ls1_dnat ?? +ls1_snat ?? +ls2_dnat ?? +ls2_snat ?? +lsp2 ?? +r1_dnat ?? +r1_snat ?? +]) + +check as hv1 ovn-appctl -t ovn-controller inc-engine/recompute +check as hv2 ovn-appctl -t ovn-controller inc-engine/recompute +AS_BOX([With patch ports after recompute]) +zone_list_hv1_after_recompute=$(as hv1 ovn-appctl -t ovn-controller ct-zone-list | sort) +zone_list_hv2_after_recompute=$(as hv2 ovn-appctl -t ovn-controller ct-zone-list | sort) +AT_CHECK([test "X$zone_list_hv1" = "X$zone_list_hv1_after_recompute"]) +AT_CHECK([test "X$zone_list_hv2" = "X$zone_list_hv2_after_recompute"]) + +OVN_CLEANUP([hv1],[hv2]) + +AT_CLEANUP +])
In ct_zones I+P, when ports changed to patch ports (e.g. from l3gateway, for which ct_zone has been allocated), delete the ct_zone. Signed-off-by: Xavier Simonart <xsimonar@redhat.com> --- controller/binding.c | 10 +++ controller/ovn-controller.c | 9 ++- tests/ovn.at | 142 ++++++++++++++++++++++++++++++++++++ 3 files changed, 160 insertions(+), 1 deletion(-)