From df44c9e5df7347f850273c9e753ffd5191d6db2b Mon Sep 17 00:00:00 2001 From: Thomas White Date: Thu, 4 Mar 2021 16:42:47 +0100 Subject: SLURM: Better handling of job cancellation/crashing --- src/gui_backend_slurm.c | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) (limited to 'src/gui_backend_slurm.c') diff --git a/src/gui_backend_slurm.c b/src/gui_backend_slurm.c index b09f7259..193685ec 100644 --- a/src/gui_backend_slurm.c +++ b/src/gui_backend_slurm.c @@ -140,11 +140,13 @@ static double indexing_progress(struct slurm_job *job, int *running) slurm_job_info_t *job_info = &array_job_info->job_array[i]; - /* Ignore the array job itself */ - if ( job_info->array_job_id == 0 ) continue; - + /* Find the array_task_id of the lowest task which is still + * running, or which might still run. Exclude the main array + * job, identified by having job_id == array_job_id. */ if ( job_alive(job_info) ) { - if ( job_info->array_task_id < lowest_alive_task ) { + if ( (job_info->array_task_id < lowest_alive_task) + && (job_info->job_id != job_info->array_job_id) ) + { lowest_alive_task = job_info->array_task_id; } n_running++; @@ -156,19 +158,11 @@ static double indexing_progress(struct slurm_job *job, int *running) /* If there are lots of blocks, just count running jobs instead of * reading loads of log files */ - if ( job->n_blocks > 15 ) { + if ( (job->n_blocks > 15) + && (lowest_alive_task < job->n_blocks) ) + { - /* Didn't find any alive jobs at all? - * Then we've either just started or just finished. */ - if ( lowest_alive_task == job->n_blocks ) { - if ( n_running > 0 ) { - return 0.0; - } else { - return 1.0; - } - } else { - return (double)lowest_alive_task / job->n_blocks; - } + return (double)lowest_alive_task / job->n_blocks; } else { -- cgit v1.2.3