At least for avoiding races in the unit tests it's useful to store the value of the OVS ovn-monitor-all external-id in the Chassis record other_config field. This allows us to know for sure when an ovn-controller has processed the update to the OVS Open_vSwitch DB table.
Signed-off-by: Dumitru Ceara <[email protected]> --- controller/chassis.c | 23 +++++++++++++++++++++-- tests/ovn.at | 8 ++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/controller/chassis.c b/controller/chassis.c index eec270e..3440d5a 100644 --- a/controller/chassis.c +++ b/controller/chassis.c @@ -84,6 +84,7 @@ struct ovs_chassis_cfg { const char *datapath_type; const char *encap_csum; const char *cms_options; + const char *monitor_all; const char *chassis_macs; /* Set of encap types parsed from the 'ovn-encap-type' external-id. */ @@ -159,6 +160,12 @@ get_cms_options(const struct smap *ext_ids) } static const char * +get_monitor_all(const struct smap *ext_ids) +{ + return smap_get_def(ext_ids, "ovn-monitor-all", "false"); +} + +static const char * get_encap_csum(const struct smap *ext_ids) { return smap_get_def(ext_ids, "ovn-encap-csum", "true"); @@ -277,6 +284,7 @@ chassis_parse_ovs_config(const struct ovsrec_open_vswitch_table *ovs_table, ovs_cfg->datapath_type = get_datapath_type(br_int); ovs_cfg->encap_csum = get_encap_csum(&cfg->external_ids); ovs_cfg->cms_options = get_cms_options(&cfg->external_ids); + ovs_cfg->monitor_all = get_monitor_all(&cfg->external_ids); ovs_cfg->chassis_macs = get_chassis_mac_mappings(&cfg->external_ids); if (!chassis_parse_ovs_encap_type(encap_type, &ovs_cfg->encap_type_set)) { @@ -303,12 +311,13 @@ chassis_parse_ovs_config(const struct ovsrec_open_vswitch_table *ovs_table, static void chassis_build_other_config(struct smap *config, const char *bridge_mappings, const char *datapath_type, const char *cms_options, - const char *chassis_macs, const char *iface_types, - bool is_interconn) + const char *monitor_all, const char *chassis_macs, + const char *iface_types, bool is_interconn) { smap_replace(config, "ovn-bridge-mappings", bridge_mappings); smap_replace(config, "datapath-type", datapath_type); smap_replace(config, "ovn-cms-options", cms_options); + smap_replace(config, "ovn-monitor-all", monitor_all); smap_replace(config, "iface-types", iface_types); smap_replace(config, "ovn-chassis-mac-mappings", chassis_macs); smap_replace(config, "is-interconn", is_interconn ? "true" : "false"); @@ -321,6 +330,7 @@ static bool chassis_other_config_changed(const char *bridge_mappings, const char *datapath_type, const char *cms_options, + const char *monitor_all, const char *chassis_macs, const struct ds *iface_types, bool is_interconn, @@ -347,6 +357,13 @@ chassis_other_config_changed(const char *bridge_mappings, return true; } + const char *chassis_monitor_all = + get_monitor_all(&chassis_rec->other_config); + + if (strcmp(monitor_all, chassis_monitor_all)) { + return true; + } + const char *chassis_mac_mappings = get_chassis_mac_mappings(&chassis_rec->other_config); if (strcmp(chassis_macs, chassis_mac_mappings)) { @@ -554,6 +571,7 @@ chassis_update(const struct sbrec_chassis *chassis_rec, if (chassis_other_config_changed(ovs_cfg->bridge_mappings, ovs_cfg->datapath_type, ovs_cfg->cms_options, + ovs_cfg->monitor_all, ovs_cfg->chassis_macs, &ovs_cfg->iface_types, ovs_cfg->is_interconn, @@ -564,6 +582,7 @@ chassis_update(const struct sbrec_chassis *chassis_rec, chassis_build_other_config(&other_config, ovs_cfg->bridge_mappings, ovs_cfg->datapath_type, ovs_cfg->cms_options, + ovs_cfg->monitor_all, ovs_cfg->chassis_macs, ds_cstr_ro(&ovs_cfg->iface_types), ovs_cfg->is_interconn); diff --git a/tests/ovn.at b/tests/ovn.at index b0179a8..2235a19 100644 --- a/tests/ovn.at +++ b/tests/ovn.at @@ -20777,6 +20777,14 @@ as hv2 ovs-vsctl del-port hv2-vif1 as hv1 ovs-vsctl set open . external_ids:ovn-monitor-all=true as hv2 ovs-vsctl set open . external_ids:ovn-monitor-all=true +# Wait until ovn-monitor-all is processed by ovn-controller. +OVS_WAIT_UNTIL([ + test $(ovn-sbctl get chassis hv1 other_config:ovn-monitor-all) = '"true"' +]) +OVS_WAIT_UNTIL([ + test $(ovn-sbctl get chassis hv2 other_config:ovn-monitor-all) = '"true"' +]) + ovn-nbctl ls-add sw0 ovn-nbctl lsp-add sw0 sw0-p1 _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
