Skip to content

Commit

Permalink
ovn-controller: Propagate nb_cfg to the local OVS DB.
Browse files Browse the repository at this point in the history
The NB.NB_Global.nb_cfg value gets propagated to
Chassis_Private.nb_cfg (and then to NB.NB_Global.hv_cfg) as soon as
ovn-controller has finished installing OVS flows corresponding to
the NB DB state.

However, if the CMS runs monitoring applications on the chassis itself,
in order to detect that the NB changes have been applied, it has to
connect to the NB/SB database.  In a scaled deployment this additional
connection might induce performance issues.

In order to avoid that we now (also) propagate nb_cfg to the local OVS
DB, in the record corresponding to the integration bridge in table
Bridge, as external_id "ovn-nb-cfg".

Signed-off-by: Dumitru Ceara <dceara@redhat.com>
Signed-off-by: Numan Siddique <numans@ovn.org>
  • Loading branch information
dceara authored and numansiddique committed Nov 19, 2020
1 parent 515ef01 commit 71e2fd2
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 13 deletions.
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ Post-v20.09.0
server.
- Support other_config:vlan-passthru=true to allow VLAN tagged incoming
traffic.
- Propagate currently processed SB_Global.nb_cfg in ovn-controller to the
local OVS DB integration bridge external_ids:ovn-nb-cfg.

OVN v20.09.0 - 28 Sep 2020
--------------------------
Expand Down
12 changes: 12 additions & 0 deletions controller/ovn-controller.8.xml
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,18 @@
logical patch port that it implements.
</p>
</dd>

<dt>
<code>external-ids:ovn-nb-cfg</code> in the <code>Bridge</code> table
</dt>

<dd>
<p>
This key represents the last known
<code>OVN_Southbound.SB_Global.nb_cfg</code> value for which all
flows have been successfully installed in OVS.
</p>
</dd>
</dl>

<h1>OVN Southbound Database Usage</h1>
Expand Down
51 changes: 38 additions & 13 deletions controller/ovn-controller.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ static unixctl_cb_func debug_delay_nb_cfg_report;

#define CONTROLLER_LOOP_STOPWATCH_NAME "ovn-controller-flow-generation"

#define OVS_NB_CFG_NAME "ovn-nb-cfg"

static char *parse_options(int argc, char *argv[]);
OVS_NO_RETURN static void usage(void);

Expand Down Expand Up @@ -792,6 +794,40 @@ get_nb_cfg(const struct sbrec_sb_global_table *sb_global_table)
return sb ? sb->nb_cfg : 0;
}

/* Propagates the local cfg seqno, 'cur_cfg', to the chassis_private record
* and to the local OVS DB.
*/
static void
store_nb_cfg(struct ovsdb_idl_txn *sb_txn, struct ovsdb_idl_txn *ovs_txn,
const struct sbrec_chassis_private *chassis,
const struct ovsrec_bridge *br_int,
unsigned int delay_nb_cfg_report,
int64_t cur_cfg)
{
if (!cur_cfg) {
return;
}

if (sb_txn && chassis && cur_cfg != chassis->nb_cfg) {
sbrec_chassis_private_set_nb_cfg(chassis, cur_cfg);
sbrec_chassis_private_set_nb_cfg_timestamp(chassis, time_wall_msec());

if (delay_nb_cfg_report) {
VLOG_INFO("Sleep for %u sec", delay_nb_cfg_report);
xsleep(delay_nb_cfg_report);
}
}

if (ovs_txn && br_int &&
cur_cfg != smap_get_ullong(&br_int->external_ids,
OVS_NB_CFG_NAME, 0)) {
char *cur_cfg_str = xasprintf("%"PRId64, cur_cfg);
ovsrec_bridge_update_external_ids_setkey(br_int, OVS_NB_CFG_NAME,
cur_cfg_str);
free(cur_cfg_str);
}
}

static const char *
get_transport_zones(const struct ovsrec_open_vswitch_table *ovs_table)
{
Expand Down Expand Up @@ -2692,19 +2728,8 @@ main(int argc, char *argv[])
engine_set_force_recompute(false);
}

if (ovnsb_idl_txn && chassis_private) {
int64_t cur_cfg = ofctrl_get_cur_cfg();
if (cur_cfg && cur_cfg != chassis_private->nb_cfg) {
sbrec_chassis_private_set_nb_cfg(chassis_private, cur_cfg);
sbrec_chassis_private_set_nb_cfg_timestamp(
chassis_private, time_wall_msec());
if (delay_nb_cfg_report) {
VLOG_INFO("Sleep for %u sec", delay_nb_cfg_report);
xsleep(delay_nb_cfg_report);
}
}
}

store_nb_cfg(ovnsb_idl_txn, ovs_idl_txn, chassis_private,
br_int, delay_nb_cfg_report, ofctrl_get_cur_cfg());

if (pending_pkt.conn) {
struct ed_type_addr_sets *as_data =
Expand Down
21 changes: 21 additions & 0 deletions tests/ovn-controller.at
Original file line number Diff line number Diff line change
Expand Up @@ -411,3 +411,24 @@ AT_CHECK([ovn-nbctl --timeout=1 --wait=hv sync])

OVN_CLEANUP([hv])
AT_CLEANUP

AT_SETUP([ovn -- nb_cfg sync to OVS])
ovn_start

net_add n1
sim_add hv1
ovs-vsctl add-br br-phys
ovn_attach n1 br-phys 192.168.0.1

# Wait for ovn-controller to register in the SB.
wait_row_count Chassis 1

# Increment nb_cfg.
check ovn-nbctl --wait=hv sync

# And check that it gets propagated to br-int external_ids.
as hv1
OVS_WAIT_UNTIL([ovs-vsctl get Bridge br-int external_ids:ovn-nb-cfg], [0], [1])

OVN_CLEANUP([hv1])
AT_CLEANUP

0 comments on commit 71e2fd2

Please sign in to comment.