Skip to content

Commit

Permalink
northd: Don't create fair Sb meters for ACLs with logging disabled.
Browse files Browse the repository at this point in the history
If the ACL.log is false for a fair meter, but ACL.meter is set in the
Northbound database, northd will create a unique meter for this ACL in
a Southbound database, even though it will never be used.

Normal ovn-nbctl acl-add command can't create such a record, but it is
possible with a plain 'ovn-nbctl set' or a direct database transaction.
And, in practice, ovn-kubernetes always sets the ACL.meter column even
if the logging is not enabled in the namespace.  This creates extra
unnecessary load on the Southbound database and the ovn-controller that
performs a linear iteration over the Southbound Meter table on every
ofctrl_put().

Logging is also not a default option, so only a fraction of ACLs will
actually need meters under normal circumstances.

Stop generating these unnecessary meters.

In an ovn-kubernetes setup with 90K ACLs 1K of which has logging
enabled this saves ~20 MB of the Southbound database file size and
about 30% of the RSS on ovsdb-server (with 1 ovn-controller connected).
Should make ofctrl_put() in ovn-controller much faster as well.

Arguably, CMS should not set ACL.meter without ACL.log, but the
behavior of the ovn-northd is not correct either, so should be fixed
anyway.

Fixes: 880dca9 ("northd: Enhance the implementation of ACL log meters (pre-ddlog merge).")
Reported-at: https://issues.redhat.com/browse/FDP-401
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
Acked-by: Mark Michelson <mmichels@redhat.com>
Acked-by: Ales Musil <amusil@redhat.com>
Signed-off-by: Mark Michelson <mmichels@redhat.com>
  • Loading branch information
igsilya authored and putnopvut committed Feb 29, 2024
1 parent f208592 commit 24ea5b2
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
8 changes: 6 additions & 2 deletions northd/en-meters.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,13 @@ sync_acl_fair_meter(struct ovsdb_idl_txn *ovnsb_txn,
const struct nbrec_acl *acl, struct shash *sb_meters,
struct sset *used_sb_meters)
{
const struct nbrec_meter *nb_meter =
fair_meter_lookup_by_name(meter_groups, acl->meter);
const struct nbrec_meter *nb_meter;

if (!acl->log || !acl->meter) {
return;
}

nb_meter = fair_meter_lookup_by_name(meter_groups, acl->meter);
if (!nb_meter) {
return;
}
Expand Down
18 changes: 18 additions & 0 deletions tests/ovn-northd.at
Original file line number Diff line number Diff line change
Expand Up @@ -2432,6 +2432,24 @@ check_acl_lflow acl_two meter_me__${acl2} sw0
check_acl_lflow acl_three meter_me__${acl3} sw0
check_acl_lflow acl_three meter_me__${acl3} sw1

AS_BOX([Disable/enable logging for acl3 while still referencing the meter])
check_row_count meter 4
check ovn-nbctl --wait=sb set acl $acl3 log=false
check_row_count meter 3
check_meter_by_name meter_me meter_me__${acl1} meter_me__${acl2}
check_meter_by_name NOT meter_me__${acl3}
check_acl_lflow acl_one meter_me__${acl1} sw0
check_acl_lflow acl_two meter_me__${acl2} sw0

check ovn-nbctl --wait=sb set acl $acl3 log=true
check_row_count meter 4
check_meter_by_name \
meter_me meter_me__${acl1} meter_me__${acl2} meter_me__${acl3}
check_acl_lflow acl_one meter_me__${acl1} sw0
check_acl_lflow acl_two meter_me__${acl2} sw0
check_acl_lflow acl_three meter_me__${acl3} sw0
check_acl_lflow acl_three meter_me__${acl3} sw1

AS_BOX([Stop using meter for acl1])
check ovn-nbctl --wait=sb clear acl $acl1 meter
check_meter_by_name meter_me meter_me__${acl2}
Expand Down

0 comments on commit 24ea5b2

Please sign in to comment.