Skip to content

Commit

Permalink
Merge pull request #5822 from grondo/jobtap-infloop-fix
Browse files Browse the repository at this point in the history
job-manager: fix infinite loop when loading builtin jobtap plugin
  • Loading branch information
mergify[bot] committed Mar 23, 2024
2 parents 93ca80d + b2c95fd commit a1070a3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/modules/job-manager/jobtap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1269,6 +1269,7 @@ static int jobtap_load_builtin_ex (struct jobtap *jobtap,
return -1;
return (*ex->init_cb) (p, ex->arg);
}
ex = zlistx_next (jobtap->builtins_ex);
}
errno = ENOENT;
return -1;
Expand Down Expand Up @@ -1430,6 +1431,13 @@ int jobtap_plugin_load_first (struct jobtap *jobtap,
return 0;
}

static bool is_builtin (const char *path)
{
/* A builtin plugin starts with '.' and does not contain a slash
*/
return (path[0] == '.' && !strchr (path, '/'));
}

flux_plugin_t * jobtap_load (struct jobtap *jobtap,
const char *path,
json_t *conf,
Expand Down Expand Up @@ -1464,7 +1472,7 @@ flux_plugin_t * jobtap_load (struct jobtap *jobtap,
if (rc < 0)
goto error;
}
if (path[0] == '.') {
if (is_builtin (path)) {
if (jobtap_load_builtin (p, path) < 0
&& jobtap_load_builtin_ex (jobtap, p, path) < 0)
goto error;
Expand Down
9 changes: 9 additions & 0 deletions t/t2212-job-manager-plugins.t
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ test_expect_success 'job-manager: attempt to load invalid plugin fails' '
test_debug "cat list2.out" &&
test_cmp list1.out list2.out
'
test_expect_success 'job-manager: loading invalid builtin plugin fails' '
test_must_fail flux jobtap load .foo
'
test_expect_success 'job-manager: builtin plugin can be removed' '
flux jobtap remove .history &&
flux jobtap list >list-nohist.out &&
test_must_fail grep ^\.history list-nohist.out &&
flux jobtap load .history
'
test_expect_success 'job-manager: load with invalid conf fails' '
cat <<-EOF >badconf.py &&
import flux
Expand Down

0 comments on commit a1070a3

Please sign in to comment.