Skip to content

Commit

Permalink
flux-kvs: support rootref on namespace create
Browse files Browse the repository at this point in the history
  • Loading branch information
chu11 committed Nov 5, 2021
1 parent f5604ff commit b317a54
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
4 changes: 3 additions & 1 deletion doc/man1/flux-kvs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,12 @@ arguments are described below.
COMMANDS
========

**namespace create** [-o owner] *name* [*name* ...]
**namespace create** [-o owner] [-r rootref] *name* [*name* ...]
Create a new kvs namespace. User may specify an alternate userid of a
user that owns the namespace via *-o*. Specifying an alternate owner
would allow a non-instance owner to read/write to a namespace.
User may specify an initial root reference for the namespace via
*-r*.

**namespace remove** *name* [*name...*]
Remove a kvs namespace.
Expand Down
14 changes: 12 additions & 2 deletions src/cmd/flux-kvs.c
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,7 @@ int cmd_namespace_create (optparse_t *p, int argc, char **argv)
int optindex, i;
uint32_t owner = FLUX_USERID_UNKNOWN;
const char *str;
const char *rootref;

optindex = optparse_option_index (p);
if ((optindex - argc) == 0) {
Expand All @@ -453,13 +454,19 @@ int cmd_namespace_create (optparse_t *p, int argc, char **argv)
log_msg_exit ("--owner requires an unsigned integer argument");
}

rootref = optparse_get_str (p, "rootref", NULL);

if (!(h = flux_open (NULL, 0)))
log_err_exit ("flux_open");

for (i = optindex; i < argc; i++) {
const char *name = argv[i];
int flags = 0;
if (!(f = flux_kvs_namespace_create (h, name, owner, flags)))
if (rootref)
f = flux_kvs_namespace_create_with (h, name, rootref, owner, flags);
else
f = flux_kvs_namespace_create (h, name, owner, flags);
if (!f)
log_err_exit ("%s", name);
if (flux_future_get (f, NULL) < 0)
log_msg_exit ("%s: %s", name, future_strerror (f, errno));
Expand Down Expand Up @@ -548,12 +555,15 @@ static struct optparse_option namespace_create_opts[] = {
{ .name = "owner", .key = 'o', .has_arg = 1,
.usage = "Specify alternate namespace owner via userid",
},
{ .name = "rootref", .key = 'r', .has_arg = 1,
.usage = "Initialize namespace with specific root reference",
},
OPTPARSE_TABLE_END
};

static struct optparse_subcommand namespace_subcommands[] = {
{ "create",
"[-o owner] name [name...]",
"[-o owner] [-r rootref] name [name...]",
"Create a KVS namespace",
cmd_namespace_create,
0,
Expand Down

0 comments on commit b317a54

Please sign in to comment.