diff mbox series

[ovs-dev,ovn,6/6] Log missing bridge per localnet port just once

Message ID 20200428203635.21822-6-ihrachys@redhat.com
State Superseded, archived
Headers show
Series [ovs-dev,ovn,1/6] Spin out flow generation into build_dhcpv4_options_flows | expand

Commit Message

Ihar Hrachyshka April 28, 2020, 8:36 p.m. UTC
Having some localnet ports missing a bridge device on a particular
chassis is a supported configuration (e.g. used to implement "routed
provider networks" for OpenStack) and should not flood logs with
duplicate messages.

Signed-off-by: Ihar Hrachyshka <ihrachys@redhat.com>
---
 controller/patch.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

Comments

Maciej Jozefczyk April 29, 2020, 11:43 a.m. UTC | #1
Hey,

I applied the series and it works with the scenario that I described
earlier.

Tested-By: Maciej Józefczyk <mjozefcz@redhat.com>

On Tue, Apr 28, 2020 at 10:37 PM Ihar Hrachyshka <ihrachys@redhat.com>
wrote:

> Having some localnet ports missing a bridge device on a particular
> chassis is a supported configuration (e.g. used to implement "routed
> provider networks" for OpenStack) and should not flood logs with
> duplicate messages.
>
> Signed-off-by: Ihar Hrachyshka <ihrachys@redhat.com>
> ---
>  controller/patch.c | 16 ++++++++++++----
>  1 file changed, 12 insertions(+), 4 deletions(-)
>
> diff --git a/controller/patch.c b/controller/patch.c
> index 52255cc3a..2a757bb00 100644
> --- a/controller/patch.c
> +++ b/controller/patch.c
> @@ -24,6 +24,7 @@
>  #include "openvswitch/hmap.h"
>  #include "openvswitch/vlog.h"
>  #include "ovn-controller.h"
> +#include "sset.h"
>
>  VLOG_DEFINE_THIS_MODULE(patch);
>
> @@ -184,6 +185,8 @@ add_bridge_mappings(struct ovsdb_idl_txn *ovs_idl_txn,
>                      const struct sbrec_chassis *chassis,
>                      const struct hmap *local_datapaths)
>  {
> +    static struct sset missed_bridges = SSET_INITIALIZER(&missed_bridges);
> +
>      /* Get ovn-bridge-mappings. */
>      struct shash bridge_mappings = SHASH_INITIALIZER(&bridge_mappings);
>
> @@ -220,20 +223,25 @@ add_bridge_mappings(struct ovsdb_idl_txn
> *ovs_idl_txn,
>                           binding->type, binding->logical_port);
>              continue;
>          }
> +        char *msg_key = xasprintf("%s;%s", binding->logical_port,
> network);
>          struct ovsrec_bridge *br_ln = shash_find_data(&bridge_mappings,
> network);
>          if (!br_ln) {
> -            static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 1);
>              if (!is_localnet) {
> +                static struct vlog_rate_limit rl =
> VLOG_RATE_LIMIT_INIT(5, 1);
>                  VLOG_ERR_RL(&rl, "bridge not found for %s port '%s' "
>                          "with network name '%s'",
>                          binding->type, binding->logical_port, network);
>              } else {
> -                VLOG_INFO_RL(&rl, "bridge not found for localnet port
> '%s' "
> -                        "with network name '%s'; skipping",
> -                        binding->logical_port, network);
> +                if (!sset_contains(&missed_bridges, msg_key)) {
> +                    VLOG_INFO("bridge not found for localnet port '%s'
> with "
> +                              "network name '%s'; skipping",
> +                              binding->logical_port, network);
> +                    sset_add(&missed_bridges, msg_key);
> +                }
>              }
>              continue;
>          }
> +        sset_find_and_delete(&missed_bridges, msg_key);
>
>          const char *patch_port_id;
>          if (is_localnet) {
> --
> 2.26.2
>
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
>
>
diff mbox series

Patch

diff --git a/controller/patch.c b/controller/patch.c
index 52255cc3a..2a757bb00 100644
--- a/controller/patch.c
+++ b/controller/patch.c
@@ -24,6 +24,7 @@ 
 #include "openvswitch/hmap.h"
 #include "openvswitch/vlog.h"
 #include "ovn-controller.h"
+#include "sset.h"
 
 VLOG_DEFINE_THIS_MODULE(patch);
 
@@ -184,6 +185,8 @@  add_bridge_mappings(struct ovsdb_idl_txn *ovs_idl_txn,
                     const struct sbrec_chassis *chassis,
                     const struct hmap *local_datapaths)
 {
+    static struct sset missed_bridges = SSET_INITIALIZER(&missed_bridges);
+
     /* Get ovn-bridge-mappings. */
     struct shash bridge_mappings = SHASH_INITIALIZER(&bridge_mappings);
 
@@ -220,20 +223,25 @@  add_bridge_mappings(struct ovsdb_idl_txn *ovs_idl_txn,
                          binding->type, binding->logical_port);
             continue;
         }
+        char *msg_key = xasprintf("%s;%s", binding->logical_port, network);
         struct ovsrec_bridge *br_ln = shash_find_data(&bridge_mappings, network);
         if (!br_ln) {
-            static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 1);
             if (!is_localnet) {
+                static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 1);
                 VLOG_ERR_RL(&rl, "bridge not found for %s port '%s' "
                         "with network name '%s'",
                         binding->type, binding->logical_port, network);
             } else {
-                VLOG_INFO_RL(&rl, "bridge not found for localnet port '%s' "
-                        "with network name '%s'; skipping",
-                        binding->logical_port, network);
+                if (!sset_contains(&missed_bridges, msg_key)) {
+                    VLOG_INFO("bridge not found for localnet port '%s' with "
+                              "network name '%s'; skipping",
+                              binding->logical_port, network);
+                    sset_add(&missed_bridges, msg_key);
+                }
             }
             continue;
         }
+        sset_find_and_delete(&missed_bridges, msg_key);
 
         const char *patch_port_id;
         if (is_localnet) {