Skip to content

Commit

Permalink
Merge pull request #6578 from grondo/issue#6576
Browse files Browse the repository at this point in the history
shell: fix lost log messages during initialization
  • Loading branch information
mergify[bot] authored Jan 24, 2025
2 parents ef85a55 + 56b82af commit 16f7233
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/shell/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ void flux_shell_raise (const char *type,
char buf [4096];
va_list ap;

if (!shell || !shell->h || logger.exception_logged)
if (!shell || !shell->h || !shell->info || logger.exception_logged)
return;

va_start (ap, fmt);
Expand Down
6 changes: 4 additions & 2 deletions src/shell/shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -1918,6 +1918,8 @@ int main (int argc, char *argv[])
{
flux_shell_t shell;

memset (&shell, 0, sizeof (shell));

/* Initialize locale from environment
*/
setlocale (LC_ALL, "");
Expand Down Expand Up @@ -1948,10 +1950,10 @@ int main (int argc, char *argv[])
* Fetches missing info from shell handle if set.
*/
if (!(shell.info = shell_info_create (&shell)))
exit (1);
shell_die (1, "failed to initialize shell info");

if (shell_export_environment_from_job (&shell) < 0)
exit (1);
shell_die (1, "failed to initialize shell environment");

/* Set verbose flag if set in attributes.system.shell.verbose */
if (flux_shell_getopt_unpack (&shell, "verbose", "i", &shell.verbose) < 0)
Expand Down
14 changes: 14 additions & 0 deletions t/t2608-job-shell-log.t
Original file line number Diff line number Diff line change
Expand Up @@ -220,4 +220,18 @@ test_expect_success 'flux-shell: stdout/err from task.exec works' '
grep "^this is stderr" print.err &&
grep "^this is stdout" print.out
'
# Note: the following test uses alloc-bypass.so to bypass the scheduler in
# order to introduce a jobspec error, to be caught by the job shell early
# in initialization.
test_expect_success 'flux-shell: early fatal errors are captured in eventlog' '
flux jobtap load alloc-bypass.so &&
id=$(flux run --dry-run -Salloc-bypass.R="$(flux resource R -i0)" true | \
jq .version=2 | \
flux job submit --flags=novalidate) &&
echo jobid=$id &&
flux job wait-event -Hvt 30 $id clean &&
test_expect_code 1 flux job attach $id >early-errors.out 2>&1 &&
grep "error parsing jobspec" early-errors.out &&
flux jobtap remove alloc-bypass.so
'
test_done

0 comments on commit 16f7233

Please sign in to comment.