Skip to content

Commit

Permalink
shell: output stdio output size warning
Browse files Browse the repository at this point in the history
Problem: If stdout or stderr becomes large, it runs the risk of
hitting the 1G limit.

Solution: If a user job outputs between 100M and 1G of stdout or
stderr, output a message to the user recommending to redirect
to a file instead.

Fixes #6269
  • Loading branch information
chu11 committed Sep 10, 2024
1 parent aef4447 commit 570b88e
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/shell/output.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@
#define SINGLEUSER_OUTPUT_LIMIT "1G"
#define MULTIUSER_OUTPUT_LIMIT "10M"
#define OUTPUT_LIMIT_MAX 1073741824
/* 104857600 = 100M */
#define OUTPUT_LIMIT_WARNING 104857600

enum {
FLUX_OUTPUT_TYPE_TERM = 1,
Expand Down Expand Up @@ -519,6 +521,24 @@ static void output_truncation_warning (struct shell_output *out)
out->stdout_bytes);
warned = true;
}
if (out->stderr_type == FLUX_OUTPUT_TYPE_KVS
&& (out->stderr_bytes > OUTPUT_LIMIT_WARNING
&& out->stderr_bytes <= OUTPUT_LIMIT_MAX)) {
shell_warn ("high stderr volume (%s), "

Check warning on line 527 in src/shell/output.c

View check run for this annotation

Codecov / codecov/patch

src/shell/output.c#L527

Added line #L527 was not covered by tests
"consider redirecting to a file next time "
"(e.g. use --output=FILE)",
encode_size (out->stderr_bytes));
warned = true;

Check warning on line 531 in src/shell/output.c

View check run for this annotation

Codecov / codecov/patch

src/shell/output.c#L531

Added line #L531 was not covered by tests
}
if (out->stdout_type == FLUX_OUTPUT_TYPE_KVS
&& (out->stdout_bytes > OUTPUT_LIMIT_WARNING
&& out->stdout_bytes <= OUTPUT_LIMIT_MAX)) {
shell_warn ("high stdout volume (%s), "

Check warning on line 536 in src/shell/output.c

View check run for this annotation

Codecov / codecov/patch

src/shell/output.c#L536

Added line #L536 was not covered by tests
"consider redirecting to a file next time "
"(e.g. use --output=FILE)",
encode_size (out->stdout_bytes));
warned = true;

Check warning on line 540 in src/shell/output.c

View check run for this annotation

Codecov / codecov/patch

src/shell/output.c#L540

Added line #L540 was not covered by tests
}
/* Ensure KVS output is flushed to eventlogger if a warning was issued:
*/
if (warned)
Expand Down

0 comments on commit 570b88e

Please sign in to comment.