Skip to content

Commit 7f68869

Browse files
garlickgrondo
authored andcommitted
job-manager: add 'final' flag to sched.free
Problem: a recent change proposed to RFC 27 says the final sched.free should contain a boolean 'final' flag indicating when the last resource fragment is being released. Set the 'final' flag to the scheduler.
1 parent 823417f commit 7f68869

File tree

3 files changed

+22
-9
lines changed

3 files changed

+22
-9
lines changed

src/modules/job-manager/alloc.c

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,16 +98,20 @@ static void interface_teardown (struct alloc *alloc, char *s, int errnum)
9898

9999
/* Send sched.free request.
100100
*/
101-
int free_request (struct alloc *alloc, flux_jobid_t id, json_t *R)
101+
int free_request (struct alloc *alloc,
102+
flux_jobid_t id,
103+
json_t *R,
104+
bool final)
102105
{
103106
flux_msg_t *msg;
104107

105108
if (!(msg = flux_request_encode ("sched.free", NULL)))
106109
return -1;
107110
if (flux_msg_pack (msg,
108-
"{s:I s:O}",
111+
"{s:I s:O s:b}",
109112
"id", id,
110-
"R", R) < 0)
113+
"R", R,
114+
"final", final) < 0)
111115
goto error;
112116
if (flux_send (alloc->ctx->h, msg, 0) < 0)
113117
goto error;
@@ -180,7 +184,7 @@ static void alloc_response_cb (flux_t *h,
180184
(void)json_object_del (R, "scheduling");
181185

182186
if (!job) {
183-
(void)free_request (alloc, id, R);
187+
(void)free_request (alloc, id, R, true);
184188
break;
185189
}
186190
if (job_priority_queue_delete (alloc->sent, job) < 0)
@@ -486,10 +490,13 @@ static void check_cb (flux_reactor_t *r,
486490
NULL);
487491
}
488492

489-
int alloc_send_free_request (struct alloc *alloc, json_t *R, flux_jobid_t id)
493+
int alloc_send_free_request (struct alloc *alloc,
494+
json_t *R,
495+
flux_jobid_t id,
496+
bool final)
490497
{
491498
if (alloc->scheduler_is_online) {
492-
if (free_request (alloc, id, R) < 0)
499+
if (free_request (alloc, id, R, final) < 0)
493500
return -1;
494501
}
495502
return 0;

src/modules/job-manager/alloc.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,10 @@ int alloc_pending_count (struct alloc *alloc);
5050

5151
/* Release resources back to the scheduler.
5252
*/
53-
int alloc_send_free_request (struct alloc *alloc, json_t *R, flux_jobid_t id);
53+
int alloc_send_free_request (struct alloc *alloc,
54+
json_t *R,
55+
flux_jobid_t id,
56+
bool final);
5457

5558
/* List pending jobs
5659
*/

src/modules/job-manager/housekeeping.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,16 +227,19 @@ static void allocation_release (struct allocation *a)
227227
struct idset *ranks = NULL;
228228
struct rlist *rl = NULL;
229229
json_t *R = NULL;
230+
bool final = false;
230231

231232
if ((ranks = get_housekept_ranks (a)) && idset_count (ranks) == 0) {
232233
idset_destroy (ranks);
233234
return; // nothing to do
234235
}
236+
if (idset_empty (a->pending))
237+
final = true;
235238

236239
if (!ranks
237240
|| !(rl = rlist_copy_ranks (a->rl, ranks))
238241
|| !(R = rlist_to_R (rl))
239-
|| alloc_send_free_request (ctx->alloc, R, a->id) < 0
242+
|| alloc_send_free_request (ctx->alloc, R, a->id, final) < 0
240243
|| rlist_remove_ranks (a->rl, ranks) < 0) {
241244
char *s = idset_encode (ranks, IDSET_FLAG_RANGE);
242245
flux_log (ctx->h,
@@ -457,7 +460,7 @@ int housekeeping_start (struct housekeeping *hk,
457460
}
458461
return 0;
459462
skip:
460-
return alloc_send_free_request (hk->ctx->alloc, R, id);
463+
return alloc_send_free_request (hk->ctx->alloc, R, id, true);
461464
}
462465

463466
static int housekeeping_hello_respond_one (struct housekeeping *hk,

0 commit comments

Comments
 (0)