save work status

This commit is contained in:
Rongsong Shen 2026-02-09 11:42:30 +08:00
parent ff6d4eeccd
commit 12a6010f29
7 changed files with 58 additions and 53 deletions

View file

@ -28,8 +28,11 @@ typedef struct {
} request_res_t; } request_res_t;
typedef struct { typedef struct {
char* user;
char* queue;
char* project;
xce_resreq_t* resreq; xce_resreq_t* resreq;
} xce_sched_resreq_t; } xce_sched_obj_t;
typedef struct { typedef struct {
char* name; char* name;
@ -59,7 +62,7 @@ typedef struct {
xce_sched_queue_t* queue; xce_sched_queue_t* queue;
xce_sched_user_t* user; xce_sched_user_t* user;
xce_sched_project_t* project; xce_sched_project_t* project;
xce_sched_resreq_t* resreq; xce_sched_obj_t* schedobj;
uint32_t mintasks; uint32_t mintasks;
uint32_t maxtasks; uint32_t maxtasks;
xce_job_alloc_t* allocs; xce_job_alloc_t* allocs;
@ -77,7 +80,8 @@ typedef struct {
typedef struct { typedef struct {
xce_sched_job_t* job; xce_sched_job_t* job;
xce_sched_worker_t* worker; xce_sched_worker_t* worker;
xce_sched_resreq_t* resreq; xce_sched_obj_t* schedobj;
xce_resreq_t* resreq;
xce_job_alloc_t* alloc; xce_job_alloc_t* alloc;
xce_pendreason_t* reason; xce_pendreason_t* reason;
struct { struct {

View file

@ -91,8 +91,8 @@ static int update_limit_res_value(zarray_t* array, xce_vres_t* vres)
static float get_vres_value(xce_sched_ctx_t* ctx, xce_vres_t* vres) static float get_vres_value(xce_sched_ctx_t* ctx, xce_vres_t* vres)
{ {
int i; int i;
xce_sched_resreq_t* resreq = ctx->resreq; xce_sched_obj_t* schedobj = ctx->schedobj;
#if 0 #if 0
if (resreq->op != RESREQ_OP_SIMPLE) { if (resreq->op != RESREQ_OP_SIMPLE) {

View file

@ -44,9 +44,9 @@ static int skip_bad_worker_(xce_sched_worker_t* w)
static int my_alloc(xce_sched_plugin_t* plugin, xce_sched_ctx_t* ctx) static int my_alloc(xce_sched_plugin_t* plugin, xce_sched_ctx_t* ctx)
{ {
xce_scheduler_t* sched = (xce_scheduler_t*)plugin->sched; xce_scheduler_t* sched = (xce_scheduler_t*)plugin->sched;
xce_sched_job_t* job = ctx->job; xce_sched_job_t* job = ctx->job;
xce_sched_resreq_t* resreq = ctx->resreq; xce_sched_obj_t* schedobj = ctx->schedobj;
return 0; return 0;
} }

View file

@ -44,13 +44,13 @@ static int skip_bad_worker_(xce_sched_worker_t* w)
static int my_alloc(xce_sched_plugin_t* plugin, xce_sched_ctx_t* ctx) static int my_alloc(xce_sched_plugin_t* plugin, xce_sched_ctx_t* ctx)
{ {
xce_scheduler_t* sched = (xce_scheduler_t*)plugin->sched; xce_scheduler_t* sched = (xce_scheduler_t*)plugin->sched;
xce_sched_job_t* job = ctx->job; xce_sched_job_t* job = ctx->job;
xce_sched_resreq_t* resreq = ctx->resreq; xce_sched_obj_t* schedobj = ctx->schedobj;
int rc; int rc;
xlist_t workers; xlist_t workers;
xce_pendreason_t* reason = NULL; xce_pendreason_t* reason = NULL;
xvec_t* uncomit = NULL; xvec_t* uncomit = NULL;
reason = make_pendreason(job->jobid); reason = make_pendreason(job->jobid);
ctx->reason = reason; ctx->reason = reason;

View file

@ -343,15 +343,15 @@ static int sched_update_res_accounts(xce_scheduler_t* sched, zarray_t* array,
static int sched_try_alloc_on_host_(xce_sched_worker_t* w, va_list ap) static int sched_try_alloc_on_host_(xce_sched_worker_t* w, va_list ap)
{ {
xce_scheduler_t* sched = va_arg(ap, xce_scheduler_t*); xce_scheduler_t* sched = va_arg(ap, xce_scheduler_t*);
xce_sched_ctx_t* ctx = va_arg(ap, xce_sched_ctx_t*); xce_sched_ctx_t* ctx = va_arg(ap, xce_sched_ctx_t*);
xce_sched_job_t* job = ctx->job; xce_sched_job_t* job = ctx->job;
xce_sched_resreq_t* resreq = ctx->resreq; xce_sched_obj_t* schedobj = ctx->schedobj;
int rc; int rc;
xce_host_alloc_t** hallocs = NULL; xce_host_alloc_t** hallocs = NULL;
xce_host_alloc_t* halloc = NULL; xce_host_alloc_t* halloc = NULL;
xce_alloc_t** allocs = NULL; xce_alloc_t** allocs = NULL;
xvec_t* uncomit = NULL; xvec_t* uncomit = NULL;
/* FIXME: */ /* FIXME: */
#if 0 #if 0

View file

@ -36,19 +36,19 @@ request_res_t* make_resource_request(char* res, float value)
return req; return req;
} }
static int make_sched_resreq(xce_sched_resreq_t* resreq, xce_scheduler_t* sched, static int make_sched_obj(xce_sched_obj_t* obj, xce_scheduler_t* sched,
xce_job_t* j) xce_job_t* j)
{ {
int rc; int rc;
char* errmsg; char* errmsg;
memset(resreq, 0x0, sizeof(*resreq)); memset(obj, 0x0, sizeof(*obj));
resreq->resreq = (xce_resreq_t*)calloc(1, sizeof(*(resreq->resreq))); obj->resreq = (xce_resreq_t*)calloc(1, sizeof(*(obj->resreq)));
if (resreq->resreq == NULL) { if (obj->resreq == NULL) {
return -EINVAL; return -EINVAL;
} }
rc = parse_resreq(resreq->resreq, j->submit->resreq, &errmsg); rc = parse_resreq(obj->resreq, j->submit->resreq, &errmsg);
if (rc < 0) { if (rc < 0) {
ERROR("%s parse_resreq with error code %d", __func__, rc); ERROR("%s parse_resreq with error code %d", __func__, rc);
if (errmsg != NULL) { if (errmsg != NULL) {
@ -84,15 +84,15 @@ xce_sched_job_t* make_sched_job(void* arg, xce_job_t* j)
job->maxtasks = j->submit->maxtasks; job->maxtasks = j->submit->maxtasks;
job->priority = 0; /* FIXME: support job level priority */ job->priority = 0; /* FIXME: support job level priority */
job->resreq = (xce_sched_resreq_t*)calloc(1, sizeof(*(job->resreq))); job->schedobj = (xce_sched_obj_t*)calloc(1, sizeof(*(job->schedobj)));
if (job->resreq == NULL) { if (job->schedobj == NULL) {
/* FIXME: */ /* FIXME: */
free(job); free(job);
return NULL; return NULL;
} }
make_sched_resreq(job->resreq, sched, j); make_sched_obj(job->schedobj, sched, j);
job->allocs = NULL; job->allocs = NULL;
job->accounts = NULL; job->accounts = NULL;
if (j->allocs != NULL) { if (j->allocs != NULL) {

View file

@ -73,25 +73,26 @@ static int sched_make_parjob_allocation(xce_scheduler_t* sched,
static int sched_make_primary_allocation(xce_scheduler_t* sched, static int sched_make_primary_allocation(xce_scheduler_t* sched,
xce_sched_ctx_t* ctx) xce_sched_ctx_t* ctx)
{ {
xce_primary_resreq_t *primary = ctx->resreq->resreq->u.primary; xce_primary_resreq_t* primary = ctx->schedobj->resreq->u.primary;
if (primary->maxTasks == 1) { if (primary->maxTasks == 1) {
return sched_make_seqjob_allocation(sched, ctx); return sched_make_seqjob_allocation(sched, ctx);
} }
return sched_make_parjob_allocation(sched, ctx); return sched_make_parjob_allocation(sched, ctx);
} }
static int sched_make_compound_allocation(xce_scheduler_t* sched, static int sched_make_compound_allocation(xce_scheduler_t* sched,
xce_sched_ctx_t* ctx) xce_sched_ctx_t* ctx)
{ {
xce_compound_resreq_t *resreq = ctx->resreq->resreq->u.compound; xce_compound_resreq_t* resreq = ctx->schedobj->resreq->u.compound;
int i; int i;
for(i = 0; i < resreq->primaries.count; i ++) { for (i = 0; i < resreq->primaries.count; i++) {
xce_primary_resreq_t *resreq1 = (xce_primary_resreq_t *)xlist_get(&(resreq->primaries), i); xce_primary_resreq_t* resreq1
int rc; = (xce_primary_resreq_t*)xlist_get(&(resreq->primaries), i);
xce_sched_ctx_t ctx1 = {0}; int rc;
xce_sched_ctx_t ctx1 = { 0 };
/* FIXME: initialize ctx1 */ /* FIXME: initialize ctx1 */
@ -99,7 +100,6 @@ static int sched_make_compound_allocation(xce_scheduler_t* sched,
if (rc <= 0) { if (rc <= 0) {
return rc; return rc;
} }
} }
return 1; return 1;
} }
@ -107,20 +107,21 @@ static int sched_make_compound_allocation(xce_scheduler_t* sched,
static int sched_make_alter_allocation(xce_scheduler_t* sched, static int sched_make_alter_allocation(xce_scheduler_t* sched,
xce_sched_ctx_t* ctx) xce_sched_ctx_t* ctx)
{ {
xce_alter_resreq_t *resreq = ctx->resreq->resreq->u.alter; xce_alter_resreq_t* resreq = ctx->schedobj->resreq->u.alter;
int i; int i;
for (i = 0; i < resreq->compounds.count; i++) {
xce_compound_resreq_t* resreq1
= (xce_compound_resreq_t*)xlist_get(&(resreq->compounds), i);
int rc;
xce_sched_ctx_t ctx1 = { 0 };
for(i = 0; i < resreq->compounds.count; i ++) {
xce_compound_resreq_t *resreq1 = (xce_compound_resreq_t *)xlist_get(&(resreq->compounds), i);
int rc;
xce_sched_ctx_t ctx1 = {0};
if (resreq1 == NULL) { if (resreq1 == NULL) {
continue; continue;
} }
/* FIXME: we need to initialize ctx1 */ /* FIXME: we need to initialize ctx1 */
rc = sched_make_compound_allocation(sched, &ctx1); rc = sched_make_compound_allocation(sched, &ctx1);
if (rc > 0) { if (rc > 0) {
return rc; return rc;
@ -134,9 +135,9 @@ static int sched_make_allocation(xce_scheduler_t* sched, xce_sched_ctx_t* ctx)
{ {
int rc = 0; int rc = 0;
xce_sched_job_t* job = ctx->job; xce_sched_job_t* job = ctx->job;
xce_resreq_t* resreq = job->resreq->resreq; xce_resreq_t* resreq = job->schedobj->resreq;
if (job->resreq == NULL) { if (job->schedobj == NULL) {
xce_pendreason_t* reason = NULL; xce_pendreason_t* reason = NULL;
ERROR("%s job %lu has invalid resource requirement", __func__, ERROR("%s job %lu has invalid resource requirement", __func__,
@ -150,7 +151,7 @@ static int sched_make_allocation(xce_scheduler_t* sched, xce_sched_ctx_t* ctx)
return 0; return 0;
} }
ctx->resreq = job->resreq; ctx->schedobj = job->schedobj;
switch (resreq->tag) { switch (resreq->tag) {
case XCE_RESREQ_PRIMARY: case XCE_RESREQ_PRIMARY:
rc = sched_make_primary_allocation(sched, ctx); rc = sched_make_primary_allocation(sched, ctx);