Skip to content

Commit 66739d2

Browse files
committed
job-manager: improve error message from limit-duration plugin
Problem: The limit-duration plugin does not include the requested duration or target queue in the error message when rejecting a job. This can lead to user confusion about the source of the policy limit. Add the requested duration (formatted as fsd) and the queue (if any) to the error message sent back to the user.
1 parent b430414 commit 66739d2

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/modules/job-manager/plugins/limit-duration.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,17 +193,24 @@ static int check_limit (struct limit_duration *ctx,
193193
{
194194
double limit = ctx->general_limit;
195195
double qlimit = queues_lookup (ctx->queues, queue);
196+
bool unlimited = duration == DURATION_UNLIMITED;
196197

197198
if (qlimit != DURATION_INVALID)
198199
limit = qlimit;
199200
if (limit != DURATION_INVALID
200201
&& limit != DURATION_UNLIMITED
201-
&& (duration > limit || duration == DURATION_UNLIMITED)) {
202+
&& (duration > limit || unlimited)) {
203+
char requested[64];
202204
char fsd[64];
205+
fsd_format_duration_ex (requested, sizeof (requested), duration, 2);
203206
fsd_format_duration_ex (fsd, sizeof (fsd), limit, 2);
204207
return errprintf (error,
205-
"requested duration exceeds policy limit of %s",
206-
fsd);
208+
"requested duration (%s) exceeds policy limit of "
209+
"%s%s%s",
210+
unlimited ? "unlimited" : requested,
211+
fsd,
212+
queue ? " for queue " : "",
213+
queue ? queue : "");
207214
}
208215
return 0;
209216
}

0 commit comments

Comments
 (0)