On Fri, Jul 24, 2020 at 7:40 PM Lorenzo Bianconi < [email protected]> wrote:
> Introduce the following commands for a cluster db running raft in order to > dump the connection status and the db role in the cluster: > > $ovs-appctl -t /var/run/ovn/ovnnb_db.ctl cluster/connected OVN_Northbound > connected > > $ovs-appctl -t /var/run/ovn/ovnnb_db.ctl cluster/role OVN_Northbound > leader > > Signed-off-by: Lorenzo Bianconi <[email protected]> > Hi Lorenzo, The patch LGTM, except one comment. Please see below. Thanks Numan > --- > ovsdb/raft.c | 43 +++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 43 insertions(+) > > diff --git a/ovsdb/raft.c b/ovsdb/raft.c > index 708b0624c..6da3fdef3 100644 > --- a/ovsdb/raft.c > +++ b/ovsdb/raft.c > @@ -4409,6 +4409,45 @@ raft_put_sid(const char *title, const struct uuid > *sid, > ds_put_char(s, '\n'); > } > > +static void > +raft_unixctl_role(struct unixctl_conn *conn, > + int argc OVS_UNUSED, const char *argv[], > + void *aux OVS_UNUSED) > +{ > + struct raft *raft = raft_lookup_by_name(argv[1]); > + if (!raft) { > + unixctl_command_reply_error(conn, "unknown cluster"); > + return; > + } > + > + struct ds s = DS_EMPTY_INITIALIZER; > + ds_put_format(&s, "%s\n", > + raft->role == RAFT_LEADER ? "leader" > + : raft->role == RAFT_CANDIDATE ? "candidate" > + : raft->role == RAFT_FOLLOWER ? "follower" > + : "<error>"); > + unixctl_command_reply(conn, ds_cstr(&s)); > + ds_destroy(&s); > +} > + > +static void > +raft_unixctl_connected(struct unixctl_conn *conn, > + int argc OVS_UNUSED, const char *argv[], > + void *aux OVS_UNUSED) > +{ > + struct raft *raft = raft_lookup_by_name(argv[1]); > + if (!raft) { > + unixctl_command_reply_error(conn, "unknown cluster"); > + return; > + } > + > + struct ds s = DS_EMPTY_INITIALIZER; > + bool connected = raft_is_connected(raft); > + ds_put_format(&s, "%s\n", connected ? "connected" : "unconnected"); > "disconnected" or "not connected" would be better. Thanks Numan > + unixctl_command_reply(conn, ds_cstr(&s)); > + ds_destroy(&s); > +} > + > static void > raft_unixctl_status(struct unixctl_conn *conn, > int argc OVS_UNUSED, const char *argv[], > @@ -4763,6 +4802,10 @@ raft_init(void) > raft_unixctl_cid, NULL); > unixctl_command_register("cluster/sid", "DB", 1, 1, > raft_unixctl_sid, NULL); > + unixctl_command_register("cluster/role", "DB", 1, 1, > + raft_unixctl_role, NULL); > + unixctl_command_register("cluster/connected", "DB", 1, 1, > + raft_unixctl_connected, NULL); > unixctl_command_register("cluster/status", "DB", 1, 1, > raft_unixctl_status, NULL); > unixctl_command_register("cluster/leave", "DB", 1, 1, > -- > 2.26.2 > > _______________________________________________ > dev mailing list > [email protected] > https://mail.openvswitch.org/mailman/listinfo/ovs-dev > > _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
