Message ID | a84621035f1030f73f1f7fd8ca75f7909a404b2c.1533050348.git.lorenzo.bianconi@redhat.com |
---|---|
State | Accepted |
Headers | show |
Series | [ovs-dev,v4] Introduce ovs-appctl command to monitor HVs sb connection status | expand |
Bleep bloop. Greetings Lorenzo Bianconi, I am a robot and I have tried out your patch. Thanks for your contribution. I encountered some error that I wasn't expecting. See the details below. build: depbase=`echo ovn/controller/lflow.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\ gcc -std=gnu99 -DHAVE_CONFIG_H -I. -I ./include -I ./include -I ./lib -I ./lib -Wstrict-prototypes -Wall -Wextra -Wno-sign-compare -Wpointer-arith -Wformat -Wformat-security -Wswitch-enum -Wunused-parameter -Wbad-function-cast -Wcast-align -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-field-initializers -fno-strict-aliasing -Wshadow -Wno-null-pointer-arithmetic -Werror -Werror -g -O2 -MT ovn/controller/lflow.o -MD -MP -MF $depbase.Tpo -c -o ovn/controller/lflow.o ovn/controller/lflow.c &&\ mv -f $depbase.Tpo $depbase.Po depbase=`echo ovn/controller/lport.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\ gcc -std=gnu99 -DHAVE_CONFIG_H -I. -I ./include -I ./include -I ./lib -I ./lib -Wstrict-prototypes -Wall -Wextra -Wno-sign-compare -Wpointer-arith -Wformat -Wformat-security -Wswitch-enum -Wunused-parameter -Wbad-function-cast -Wcast-align -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-field-initializers -fno-strict-aliasing -Wshadow -Wno-null-pointer-arithmetic -Werror -Werror -g -O2 -MT ovn/controller/lport.o -MD -MP -MF $depbase.Tpo -c -o ovn/controller/lport.o ovn/controller/lport.c &&\ mv -f $depbase.Tpo $depbase.Po depbase=`echo ovn/controller/ofctrl.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\ gcc -std=gnu99 -DHAVE_CONFIG_H -I. -I ./include -I ./include -I ./lib -I ./lib -Wstrict-prototypes -Wall -Wextra -Wno-sign-compare -Wpointer-arith -Wformat -Wformat-security -Wswitch-enum -Wunused-parameter -Wbad-function-cast -Wcast-align -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-field-initializers -fno-strict-aliasing -Wshadow -Wno-null-pointer-arithmetic -Werror -Werror -g -O2 -MT ovn/controller/ofctrl.o -MD -MP -MF $depbase.Tpo -c -o ovn/controller/ofctrl.o ovn/controller/ofctrl.c &&\ mv -f $depbase.Tpo $depbase.Po ovn/controller/ofctrl.c: In function ‘ofctrl_put’: ovn/controller/ofctrl.c:1086:9: error: missing initializer for field ‘flags’ of ‘struct ofputil_meter_config’ [-Werror=missing-field-initializers] }; ^ In file included from ovn/controller/ofctrl.c:35:0: ./include/openvswitch/ofp-meter.h:53:14: note: ‘flags’ declared here uint16_t flags; ^ ovn/controller/ofctrl.c: At top level: cc1: error: unrecognized command line option "-Wno-null-pointer-arithmetic" [-Werror] cc1: all warnings being treated as errors make[2]: *** [ovn/controller/ofctrl.o] Error 1 make[2]: Leaving directory `/var/lib/jenkins/jobs/upstream_build_from_pw/workspace' make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory `/var/lib/jenkins/jobs/upstream_build_from_pw/workspace' make: *** [all] Error 2 Please check this out. If you feel there has been an error, please email aconole@bytheb.org Thanks, 0-day Robot
On Tue, Jul 31, 2018 at 05:35:00PM +0200, Lorenzo Bianconi wrote: > Add 'connection-status' command to ovs-appctl utility in order to check > if a given chassis is currently connected to SB db > > Acked-by: Mark Michelson <mmichels@redhat.com> > Co-authored-by: aginwala <aginwala@ebay.com> > Signed-off-by: aginwala <aginwala@ebay.com> > Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com> Thanks, applied to master.
On Tue, 31 Jul 2018 17:35:00 +0200 Lorenzo Bianconi <lorenzo.bianconi@redhat.com> wrote: > Add 'connection-status' command to ovs-appctl utility in order to check > if a given chassis is currently connected to SB db > > Acked-by: Mark Michelson <mmichels@redhat.com> > Co-authored-by: aginwala <aginwala@ebay.com> > Signed-off-by: aginwala <aginwala@ebay.com> > Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com> > --- > Changes since v3: > - add const qualifier to result and idl pointers in > ovn_controller_conn_show routine > - remove idl check before running ovsdb_idl_is_connected routine > Changes since v2: > - check idl->session pointer in ovsdb_idl_is_connected routine > Changes since v1: > - add unit tests for ovs-appctl -t ovn-controller connection-status > command > - use jsonrpc_session_is_connected() in ovsdb_idl_is_connected routine > --- Thanks for the fix-ups. Acked-by: Jakub Sitnicki <jkbs@redhat.com>
On Tue, Jul 31, 2018 at 12:51:02PM -0700, Ben Pfaff wrote: > On Tue, Jul 31, 2018 at 05:35:00PM +0200, Lorenzo Bianconi wrote: > > Add 'connection-status' command to ovs-appctl utility in order to check > > if a given chassis is currently connected to SB db > > > > Acked-by: Mark Michelson <mmichels@redhat.com> > > Co-authored-by: aginwala <aginwala@ebay.com> > > Signed-off-by: aginwala <aginwala@ebay.com> > > Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com> > > Thanks, applied to master. Howdy, any chance to get this one applied to branch-2.10? Thanks,
On Fri, Aug 17, 2018 at 10:18:36AM -0300, Flavio Leitner wrote: > On Tue, Jul 31, 2018 at 12:51:02PM -0700, Ben Pfaff wrote: > > On Tue, Jul 31, 2018 at 05:35:00PM +0200, Lorenzo Bianconi wrote: > > > Add 'connection-status' command to ovs-appctl utility in order to check > > > if a given chassis is currently connected to SB db > > > > > > Acked-by: Mark Michelson <mmichels@redhat.com> > > > Co-authored-by: aginwala <aginwala@ebay.com> > > > Signed-off-by: aginwala <aginwala@ebay.com> > > > Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com> > > > > Thanks, applied to master. > > Howdy, any chance to get this one applied to branch-2.10? Done.
On Fri, Aug 17, 2018 at 09:35:37AM -0700, Ben Pfaff wrote: > On Fri, Aug 17, 2018 at 10:18:36AM -0300, Flavio Leitner wrote: > > On Tue, Jul 31, 2018 at 12:51:02PM -0700, Ben Pfaff wrote: > > > On Tue, Jul 31, 2018 at 05:35:00PM +0200, Lorenzo Bianconi wrote: > > > > Add 'connection-status' command to ovs-appctl utility in order to check > > > > if a given chassis is currently connected to SB db > > > > > > > > Acked-by: Mark Michelson <mmichels@redhat.com> > > > > Co-authored-by: aginwala <aginwala@ebay.com> > > > > Signed-off-by: aginwala <aginwala@ebay.com> > > > > Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com> > > > > > > Thanks, applied to master. > > > > Howdy, any chance to get this one applied to branch-2.10? > > Done. Thank you!
diff --git a/lib/ovsdb-idl.c b/lib/ovsdb-idl.c index ae0a55c3a..40c29cbd1 100644 --- a/lib/ovsdb-idl.c +++ b/lib/ovsdb-idl.c @@ -922,6 +922,12 @@ ovsdb_idl_is_alive(const struct ovsdb_idl *idl) idl->state != IDL_S_ERROR; } +bool +ovsdb_idl_is_connected(const struct ovsdb_idl *idl) +{ + return idl->session && jsonrpc_session_is_connected(idl->session); +} + /* Returns the last error reported on a connection by 'idl'. The return value * is 0 only if no connection made by 'idl' has ever encountered an error and * a negative response to a schema request has never been received. See diff --git a/lib/ovsdb-idl.h b/lib/ovsdb-idl.h index ea18b22f5..5f933b628 100644 --- a/lib/ovsdb-idl.h +++ b/lib/ovsdb-idl.h @@ -80,6 +80,7 @@ void ovsdb_idl_force_reconnect(struct ovsdb_idl *); void ovsdb_idl_verify_write_only(struct ovsdb_idl *); bool ovsdb_idl_is_alive(const struct ovsdb_idl *); +bool ovsdb_idl_is_connected(const struct ovsdb_idl *idl); int ovsdb_idl_get_last_error(const struct ovsdb_idl *); void ovsdb_idl_set_probe_interval(const struct ovsdb_idl *, int probe_interval); diff --git a/ovn/controller/ovn-controller.8.xml b/ovn/controller/ovn-controller.8.xml index 2e4e53d6b..8035638b3 100644 --- a/ovn/controller/ovn-controller.8.xml +++ b/ovn/controller/ovn-controller.8.xml @@ -398,6 +398,11 @@ 0x800</code>. </p> </dd> + + <dt><code>connection-status</code></dt> + <dd> + Show OVN SBDB connection status for the chassis. + </dd> </dl> </p> diff --git a/ovn/controller/ovn-controller.c b/ovn/controller/ovn-controller.c index 470e02ae8..81d330683 100644 --- a/ovn/controller/ovn-controller.c +++ b/ovn/controller/ovn-controller.c @@ -68,6 +68,7 @@ static unixctl_cb_func ct_zone_list; static unixctl_cb_func meter_table_list; static unixctl_cb_func group_table_list; static unixctl_cb_func inject_pkt; +static unixctl_cb_func ovn_controller_conn_show; #define DEFAULT_BRIDGE_NAME "br-int" #define DEFAULT_PROBE_INTERVAL_MSEC 5000 @@ -594,6 +595,9 @@ main(int argc, char *argv[]) ovsdb_idl_create(ovnsb_remote, &sbrec_idl_class, true, true)); ovsdb_idl_set_leader_only(ovnsb_idl_loop.idl, false); + unixctl_command_register("connection-status", "", 0, 0, + ovn_controller_conn_show, ovnsb_idl_loop.idl); + struct ovsdb_idl_index *sbrec_chassis_by_name = chassis_index_create(ovnsb_idl_loop.idl); struct ovsdb_idl_index *sbrec_multicast_group_by_name_datapath @@ -1122,3 +1126,16 @@ update_probe_interval(const struct ovsrec_open_vswitch_table *ovs_table, ovsdb_idl_set_probe_interval(ovnsb_idl, interval); } + +static void +ovn_controller_conn_show(struct unixctl_conn *conn, int argc OVS_UNUSED, + const char *argv[] OVS_UNUSED, void *idl_) +{ + const char *result = "not connected"; + const struct ovsdb_idl *idl = idl_; + + if (ovsdb_idl_is_connected(idl)) { + result = "connected"; + } + unixctl_command_reply(conn, result); +} diff --git a/tests/ovn-controller.at b/tests/ovn-controller.at index ecc6a50da..13e88a0cc 100644 --- a/tests/ovn-controller.at +++ b/tests/ovn-controller.at @@ -228,3 +228,37 @@ as ovn-sb OVS_APP_EXIT_AND_WAIT([ovsdb-server]) AT_CLEANUP + +# Check ovn-controller connection status to Southbound database +AT_SETUP([ovn-controller - check sbdb connection]) +AT_KEYWORDS([ovn]) +ovn_init_db ovn-sb + +net_add n1 +sim_add hv +as hv +ovs-vsctl \ + -- add-br br-phys \ + -- add-br br-eth0 \ + -- add-br br-eth1 \ + -- add-br br-eth2 +ovn_attach n1 br-phys 192.168.0.1 + +check_sbdb_connection () { + test "$(ovs-appctl -t ovn-controller connection-status)" = "$1" +} + +OVS_WAIT_UNTIL([check_sbdb_connection connected]) + +ovs-vsctl set open . external_ids:ovn-remote=tcp:192.168.0.10:6642 +OVS_WAIT_UNTIL([check_sbdb_connection 'not connected']) + +# reset the remote for clean-up +ovs-vsctl set open . external_ids:ovn-remote=unix:$ovs_base/ovn-sb/ovn-sb.sock +# Gracefully terminate daemons +OVN_CLEANUP_SBOX([hv]) +OVN_CLEANUP_VSWITCH([main]) +as ovn-sb +OVS_APP_EXIT_AND_WAIT([ovsdb-server]) + +AT_CLEANUP