Skip to content

Commit

Permalink
job-exec: use flux_job_kvs_namespace() to create namespace name
Browse files Browse the repository at this point in the history
Switch to using libjob's flux_job_kvs_namespace() to create job
guest kvs namespace names, instead of using the dothex notiation
of a flux_jobid_t.

This puts job namespace name generation in a single place so that
these names do not have to be generated manually anywhere, as
well as allowing the naming convention to be updated in the future
without breaking any existing code.

As a side effect, this fixes a problematic side effect of kvs
namespace names with periods in them, since these names are
used as keys in kvs module stats output.

Fixes #2306
  • Loading branch information
grondo committed Aug 16, 2019
1 parent fde72bc commit 2332ea0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 9 deletions.
9 changes: 1 addition & 8 deletions src/modules/job-exec/job-exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -819,13 +819,6 @@ static flux_future_t *jobinfo_start_init (struct jobinfo *job)
return NULL;
}

/* Create namespace name for jobid 'id'
*/
static int job_get_ns_name (char *buf, int bufsz, flux_jobid_t id)
{
return fluid_encode (buf, bufsz, id, FLUID_STRING_DOTHEX);
}

static double job_get_kill_timeout (flux_t *h)
{
double t = DEFAULT_KILL_TIMEOUT;
Expand Down Expand Up @@ -866,7 +859,7 @@ static int job_start (struct job_exec_ctx *ctx, const flux_msg_t *msg)
jobinfo_decref (job);
return -1;
}
if (job_get_ns_name (job->ns, sizeof (job->ns), job->id) < 0) {
if (flux_job_kvs_namespace (job->ns, sizeof (job->ns), job->id) < 0) {
jobinfo_fatal_error (job, errno, "failed to create ns name for job");
flux_log_error (ctx->h, "job_ns_create");
return -1;
Expand Down
2 changes: 1 addition & 1 deletion t/t2402-job-exec-dummy.t
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ test_expect_success 'job-exec: job exception uses SIGKILL after kill-timeout' '
| flux job submit) &&
flux job wait-event -vt 1 $id start &&
flux kvs get --waitcreate \
--namespace=$(flux job id --to=hex $id) \
--namespace=$(flux job namespace $id) \
trap-ready &&
flux job cancel $id &&
sleep 0.2 &&
Expand Down

0 comments on commit 2332ea0

Please sign in to comment.