From 1f0c210fed36a0b520652dba538d2d124c9d2e91 Mon Sep 17 00:00:00 2001 From: Danny Auble <da@schedmd.com> Date: Fri, 29 Aug 2014 15:50:55 -0700 Subject: [PATCH] Handle WAIT_ARRAY_TASK_LIMIT in accounting by setting begin_time to -1 which won't accrue time until the job is actually able to run and then set the begin_time to time(NULL) --- .../accounting_storage/mysql/as_mysql_job.c | 13 +++++++++++-- .../slurmdbd/accounting_storage_slurmdbd.c | 8 ++++++++ src/slurmctld/job_mgr.c | 18 ++++++++++++++++++ 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/src/plugins/accounting_storage/mysql/as_mysql_job.c b/src/plugins/accounting_storage/mysql/as_mysql_job.c index e352a3c0189..84341e1855f 100644 --- a/src/plugins/accounting_storage/mysql/as_mysql_job.c +++ b/src/plugins/accounting_storage/mysql/as_mysql_job.c @@ -276,6 +276,14 @@ extern int as_mysql_job_start(mysql_conn_t *mysql_conn, start_time = job_ptr->start_time; } + /* If the reason is WAIT_ARRAY_TASK_LIMIT we don't want to + * give the pending jobs an eligible time since it will add + * time to accounting where as these jobs aren't able to run + * until later so mark it as such. + */ + if (job_ptr->state_reason == WAIT_ARRAY_TASK_LIMIT) + begin_time = INFINITE; + /* Since we need a new db_inx make sure the old db_inx * removed. This is most likely the only time we are going to * be notified of the change also so make the state without @@ -520,14 +528,15 @@ no_rollup_change: "job_db_inx=LAST_INSERT_ID(job_db_inx), " "id_wckey=%u, id_user=%u, id_group=%u, " "nodelist='%s', id_resv=%u, timelimit=%u, " - "time_submit=%ld, time_start=%ld, " + "time_submit=%ld, time_eligible=%ld, " + "time_start=%ld, " "job_name='%s', track_steps=%u, id_qos=%u, " "state=greatest(state, %u), priority=%u, " "cpus_req=%u, cpus_alloc=%u, nodes_alloc=%u, " "mem_req=%u, id_array_job=%u, id_array_task=%u", wckeyid, job_ptr->user_id, job_ptr->group_id, nodes, job_ptr->resv_id, job_ptr->time_limit, - submit_time, start_time, + submit_time, begin_time, start_time, jname, track_steps, job_ptr->qos_id, job_state, job_ptr->priority, job_ptr->details->min_cpus, job_ptr->total_cpus, node_cnt, diff --git a/src/plugins/accounting_storage/slurmdbd/accounting_storage_slurmdbd.c b/src/plugins/accounting_storage/slurmdbd/accounting_storage_slurmdbd.c index 6adaaa08d78..29309514e87 100644 --- a/src/plugins/accounting_storage/slurmdbd/accounting_storage_slurmdbd.c +++ b/src/plugins/accounting_storage/slurmdbd/accounting_storage_slurmdbd.c @@ -183,6 +183,14 @@ static int _setup_job_start_msg(dbd_job_start_msg_t *req, req->submit_time = job_ptr->details->submit_time; } + /* If the reason is WAIT_ARRAY_TASK_LIMIT we don't want to + * give the pending jobs an eligible time since it will add + * time to accounting where as these jobs aren't able to run + * until later so mark it as such. + */ + if (job_ptr->state_reason == WAIT_ARRAY_TASK_LIMIT) + req->eligible_time = INFINITE; + req->start_time = job_ptr->start_time; req->gid = job_ptr->group_id; req->job_id = job_ptr->job_id; diff --git a/src/slurmctld/job_mgr.c b/src/slurmctld/job_mgr.c index 0e5b605ce27..80c99881cc7 100644 --- a/src/slurmctld/job_mgr.c +++ b/src/slurmctld/job_mgr.c @@ -3464,6 +3464,15 @@ struct job_record *_job_rec_copy(struct job_record *job_ptr) save_step_list = job_ptr_pend->step_list; memcpy(job_ptr_pend, job_ptr, sizeof(struct job_record)); + /* This means the job was once limited by the number + * of tasks it was able to run so the eligible time of + * the job needs to be set to NOW. + */ + if (job_ptr->array_recs && job_ptr->array_recs->max_run_tasks && + (job_ptr->array_recs->tot_run_tasks >= + job_ptr->array_recs->max_run_tasks)) + job_ptr->details->begin_time = time(NULL); + job_ptr_pend->job_id = save_job_id; job_ptr_pend->job_next = save_job_next; job_ptr_pend->details = save_details; @@ -13726,6 +13735,15 @@ extern void job_array_post_sched(struct job_record *job_ptr) return; if (job_ptr->array_recs->task_cnt <= 1) { + /* This means the job was once limited by the number + * of tasks it was able to run so the eligible time of + * the job needs to be set to NOW. + */ + if (job_ptr->array_recs && job_ptr->array_recs->max_run_tasks && + (job_ptr->array_recs->tot_run_tasks >= + job_ptr->array_recs->max_run_tasks)) + job_ptr->details->begin_time = time(NULL); + /* Preserve array_recs for min/max exit codes for job array */ if (job_ptr->array_recs->task_cnt) { job_ptr->array_recs->task_cnt--; -- GitLab