Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

broker: drop -k-ary option, rename tbon.arity attribute to tbon.fanout #3796

Merged
merged 3 commits into from
Jul 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions doc/man1/flux-broker.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@ OPTIONS
**-S, --setattr**\ =\ *ATTR=VAL*
Set initial value for broker attribute.

**-k, --k-ary**\ =\ *N*
Set the branching factor of the tree based overlay
network (default: 2).


RESOURCES
=========
Expand Down
2 changes: 1 addition & 1 deletion doc/man7/flux-broker-attributes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ content.backing-path
TOPOLOGY ATTRIBUTES
===================

tbon.arity
tbon.fanout
Branching factor of the tree based overlay network.

tbon.descendants
Expand Down
1 change: 0 additions & 1 deletion doc/test/spell.en.pws
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,6 @@ tinfo
hwloc
epgm
args
arity
attr
ATTRFLAG
ENOENT
Expand Down
2 changes: 1 addition & 1 deletion etc/flux.service.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ TimeoutStopSec=90
KillMode=mixed
ExecStart=@X_BINDIR@/flux broker \
--config-path=@X_SYSCONFDIR@/flux/system/conf.d \
--k-ary=256 \
-Stbon.fanout=256 \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should the commit message header be "rename tbon.arity"? Preferable is "rename tbon.arity to tbon.fanout", but I assume that would make the line too long.

-Srundir=@X_RUNSTATEDIR@/flux \
-Slocal-uri=local://@X_RUNSTATEDIR@/flux/local \
-Slog-stderr-level=6 \
Expand Down
16 changes: 8 additions & 8 deletions src/bindings/lua/flux-lua.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,16 +235,16 @@ static int l_flux_size (lua_State *L)
return (l_pushresult (L, size));
}

static int l_flux_arity (lua_State *L)
static int l_flux_fanout (lua_State *L)
{
flux_t *f = lua_get_flux (L, 1);
const char *s;
int arity;
int fanout;

if (!(s = flux_attr_get (f, "tbon.arity")))
return lua_pusherror (L, "flux_attr_get tbon.arity error");
arity = strtoul (s, NULL, 10);
return (l_pushresult (L, arity));
if (!(s = flux_attr_get (f, "tbon.fanout")))
return lua_pusherror (L, "flux_attr_get tbon.fanout error");
fanout = strtoul (s, NULL, 10);
return (l_pushresult (L, fanout));
}

static int l_flux_index (lua_State *L)
Expand All @@ -258,8 +258,8 @@ static int l_flux_index (lua_State *L)
return l_flux_size (L);
if (strcmp (key, "rank") == 0)
return l_flux_rank (L);
if (strcmp (key, "arity") == 0)
return l_flux_arity (L);
if (strcmp (key, "fanout") == 0)
return l_flux_fanout (L);

lua_getmetatable (L, 1);
lua_getfield (L, -1, key);
Expand Down
10 changes: 9 additions & 1 deletion src/broker/attr.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ int attr_add (attr_t *attrs, const char *name, const char *val, int flags)
{
struct entry *e;

if (name == NULL || (flags & FLUX_ATTRFLAG_ACTIVE)) {
if (attrs == NULL || name == NULL || (flags & FLUX_ATTRFLAG_ACTIVE)) {
errno = EINVAL;
return -1;
}
Expand All @@ -109,6 +109,10 @@ int attr_add_active (attr_t *attrs, const char *name, int flags,
struct entry *e;
int rc = -1;

if (!attrs) {
errno = EINVAL;
goto done;
}
if ((e = zhash_lookup (attrs->hash, name))) {
if (!set) {
errno = EEXIST;
Expand All @@ -134,6 +138,10 @@ int attr_get (attr_t *attrs, const char *name, const char **val, int *flags)
struct entry *e;
int rc = -1;

if (!attrs || !name) {
errno = EINVAL;
goto done;
}
if (!(e = zhash_lookup (attrs->hash, name))) {
errno = ENOENT;
goto done;
Expand Down
11 changes: 6 additions & 5 deletions src/broker/boot_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -439,11 +439,12 @@ int boot_config_geturibyrank (json_t *hosts,
return 0;
}

int boot_config (flux_t *h, struct overlay *overlay, attr_t *attrs, int tbon_k)
int boot_config (flux_t *h, struct overlay *overlay, attr_t *attrs)
{
struct boot_conf conf;
uint32_t rank;
uint32_t size;
int fanout = overlay_get_fanout (overlay);
json_t *hosts = NULL;

/* Ingest the [bootstrap] stanza.
Expand Down Expand Up @@ -476,10 +477,10 @@ int boot_config (flux_t *h, struct overlay *overlay, attr_t *attrs, int tbon_k)
rank = 0;
}

/* Tell overlay network this broker's rank, size, and branching factor.
/* Tell overlay network this broker's rank and size.
* If a curve certificate was provided, load it.
*/
if (overlay_set_geometry (overlay, size, rank, tbon_k) < 0)
if (overlay_set_geometry (overlay, size, rank) < 0)
goto error;
if (conf.curve_cert) {
if (overlay_cert_load (overlay, conf.curve_cert) < 0)
Expand All @@ -491,7 +492,7 @@ int boot_config (flux_t *h, struct overlay *overlay, attr_t *attrs, int tbon_k)
* attribute to the URI peers will connect to. If broker has no
* downstream peers, set tbon.endpoint to NULL.
*/
if (kary_childof (tbon_k, size, rank, 0) != KARY_NONE) {
if (kary_childof (fanout, size, rank, 0) != KARY_NONE) {
char bind_uri[MAX_URI + 1];
char my_uri[MAX_URI + 1];

Expand Down Expand Up @@ -543,7 +544,7 @@ int boot_config (flux_t *h, struct overlay *overlay, attr_t *attrs, int tbon_k)
char parent_uri[MAX_URI + 1];
if (boot_config_geturibyrank (hosts,
&conf,
kary_parentof (tbon_k, rank),
kary_parentof (fanout, rank),
parent_uri,
sizeof (parent_uri)) < 0)
goto error;
Expand Down
2 changes: 1 addition & 1 deletion src/broker/boot_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* tbon.endpoint (w)
* instance-level (w)
*/
int boot_config (flux_t *h, struct overlay *overlay, attr_t *attrs, int tbon_k);
int boot_config (flux_t *h, struct overlay *overlay, attr_t *attrs);

/* The following is exported for unit testing.
*/
Expand Down
14 changes: 7 additions & 7 deletions src/broker/boot_pmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,9 @@ static int format_bind_uri (char *buf, int bufsz, attr_t *attrs, int rank)
return -1;
}

int boot_pmi (struct overlay *overlay, attr_t *attrs, int tbon_k)
int boot_pmi (struct overlay *overlay, attr_t *attrs)
{
int fanout = overlay_get_fanout (overlay);
int rank;
char key[64];
char val[1024];
Expand Down Expand Up @@ -184,8 +185,7 @@ int boot_pmi (struct overlay *overlay, attr_t *attrs, int tbon_k)
}
if (overlay_set_geometry (overlay,
pmi_params.size,
pmi_params.rank,
tbon_k) < 0)
pmi_params.rank) < 0)
goto error;

/* A size=1 instance has no peers, so skip the PMI exchange.
Expand All @@ -198,7 +198,7 @@ int boot_pmi (struct overlay *overlay, attr_t *attrs, int tbon_k)
* N.B. there are no downstream peers if the 0th child of this rank
* in k-ary tree does not exist.
*/
if (kary_childof (tbon_k,
if (kary_childof (fanout,
pmi_params.size,
pmi_params.rank,
0) != KARY_NONE) {
Expand Down Expand Up @@ -259,7 +259,7 @@ int boot_pmi (struct overlay *overlay, attr_t *attrs, int tbon_k)
if (pmi_params.rank > 0) {
char *cp;

rank = kary_parentof (tbon_k, pmi_params.rank);
rank = kary_parentof (fanout, pmi_params.rank);
if (snprintf (key, sizeof (key), "%d", rank) >= sizeof (key)) {
log_msg ("pmi key string overflow");
goto error;
Expand Down Expand Up @@ -288,10 +288,10 @@ int boot_pmi (struct overlay *overlay, attr_t *attrs, int tbon_k)

/* Fetch the business card of children and inform overlay of public keys.
*/
for (i = 0; i < tbon_k; i++) {
for (i = 0; i < fanout; i++) {
char *cp;

rank = kary_childof (tbon_k, pmi_params.size, pmi_params.rank, i);
rank = kary_childof (fanout, pmi_params.size, pmi_params.rank, i);
if (rank == KARY_NONE)
break;
if (snprintf (key, sizeof (key), "%d", rank) >= sizeof (key)) {
Expand Down
2 changes: 1 addition & 1 deletion src/broker/boot_pmi.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include "attr.h"
#include "overlay.h"

int boot_pmi (struct overlay *overlay, attr_t *attrs, int tbon_k);
int boot_pmi (struct overlay *overlay, attr_t *attrs);

#endif /* BROKER_BOOT_PMI_H */

Expand Down
16 changes: 7 additions & 9 deletions src/broker/broker.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,6 @@ static const struct flux_handle_ops broker_handle_ops;
static struct optparse_option opts[] = {
{ .name = "verbose", .key = 'v', .has_arg = 2, .arginfo = "[LEVEL]",
.usage = "Be annoyingly informative by degrees", },
{ .name = "k-ary", .key = 'k', .has_arg = 1, .arginfo = "K",
.usage = "Wire up in a k-ary tree (default: 2)", },
{ .name = "setattr", .key = 'S', .has_arg = 1, .arginfo = "ATTR=VAL",
.usage = "Set broker attribute", },
{ .name = "config-path",.key = 'c', .has_arg = 1, .arginfo = "PATH",
Expand All @@ -128,9 +126,6 @@ void parse_command_line_arguments (int argc, char *argv[], broker_ctx_t *ctx)

ctx->verbose = optparse_get_int (ctx->opts, "verbose", 0);

if ((ctx->tbon_k = optparse_get_int (ctx->opts, "k-ary", 2)) < 1)
log_msg_exit ("--k-ary value must be >= 1");

optparse_get_str (ctx->opts, "config-path", NULL);

while ((arg = optparse_getopt_next (ctx->opts, "setattr"))) {
Expand Down Expand Up @@ -275,7 +270,10 @@ int main (int argc, char *argv[])
goto cleanup;
}

if (!(ctx.overlay = overlay_create (ctx.h, overlay_recv_cb, &ctx))) {
if (!(ctx.overlay = overlay_create (ctx.h,
ctx.attrs,
overlay_recv_cb,
&ctx))) {
log_err ("overlay_create");
goto cleanup;
}
Expand All @@ -299,13 +297,13 @@ int main (int argc, char *argv[])
*/
monotime (&boot_start_time);
if (flux_conf_unpack (conf, NULL, "{s:{}}", "bootstrap") == 0) {
if (boot_config (ctx.h, ctx.overlay, ctx.attrs, ctx.tbon_k) < 0) {
if (boot_config (ctx.h, ctx.overlay, ctx.attrs) < 0) {
log_msg ("bootstrap failed");
goto cleanup;
}
}
else { // PMI
if (boot_pmi (ctx.overlay, ctx.attrs, ctx.tbon_k) < 0) {
if (boot_pmi (ctx.overlay, ctx.attrs) < 0) {
log_msg ("bootstrap failed");
goto cleanup;
}
Expand All @@ -318,7 +316,7 @@ int main (int argc, char *argv[])
assert (ctx.size > 0);

/* Must be called after overlay setup */
if (overlay_register_attrs (ctx.overlay, ctx.attrs) < 0) {
if (overlay_register_attrs (ctx.overlay) < 0) {
log_err ("registering overlay attributes");
goto cleanup;
}
Expand Down
1 change: 0 additions & 1 deletion src/broker/broker.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ struct broker {
zlist_t *subscriptions; /* subscripts for internal services */
struct content_cache *cache;
struct publisher *publisher;
int tbon_k;

struct runat *runat;
struct state_machine *state_machine;
Expand Down
Loading