From 570b88e61f5d9b574b12db6d81328368cbf7fd2f Mon Sep 17 00:00:00 2001 From: Albert Chu Date: Mon, 9 Sep 2024 12:55:54 -0700 Subject: [PATCH] shell: output stdio output size warning 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 --- src/shell/output.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/shell/output.c b/src/shell/output.c index 31da3fe951e7..d439d3151c4c 100644 --- a/src/shell/output.c +++ b/src/shell/output.c @@ -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, @@ -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), " + "consider redirecting to a file next time " + "(e.g. use --output=FILE)", + encode_size (out->stderr_bytes)); + warned = true; + } + 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), " + "consider redirecting to a file next time " + "(e.g. use --output=FILE)", + encode_size (out->stdout_bytes)); + warned = true; + } /* Ensure KVS output is flushed to eventlogger if a warning was issued: */ if (warned)