From 83e291a8a1f9b3dd9da0b53c49ae140878f875b0 Mon Sep 17 00:00:00 2001 From: Moe Jette <jette1@llnl.gov> Date: Mon, 19 Mar 2007 23:17:59 +0000 Subject: [PATCH] svn merge -r11177:11200 https://eris.llnl.gov/svn/slurm/branches/slurm-1.1 --- NEWS | 1 + src/plugins/sched/wiki2/job_modify.c | 49 +++++++++++++++++++++------- testsuite/expect/test7.7.prog.c | 8 +++-- 3 files changed, 43 insertions(+), 15 deletions(-) diff --git a/NEWS b/NEWS index 797898f4528..1dea125cd26 100644 --- a/NEWS +++ b/NEWS @@ -256,6 +256,7 @@ documents those changes that are of interest to users and admins. Gilles Civario (Bull). - sched/wiki2 - Report job's node sharing options. - sched/wiki2 - If SchedulerPort is in use, retry opening it indefinitely. + - sched/wiki2 - Add support for changing the size of a pending job. * Changes in SLURM 1.1.32 ========================= diff --git a/src/plugins/sched/wiki2/job_modify.c b/src/plugins/sched/wiki2/job_modify.c index 8ca603e24c1..884414bf54e 100644 --- a/src/plugins/sched/wiki2/job_modify.c +++ b/src/plugins/sched/wiki2/job_modify.c @@ -1,7 +1,7 @@ /*****************************************************************************\ * job_modify.c - Process Wiki job modify request ***************************************************************************** - * Copyright (C) 2006 The Regents of the University of California. + * Copyright (C) 2006-2007 The Regents of the University of California. * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). * Written by Morris Jette <jette1@llnl.gov> * UCRL-CODE-226842. @@ -53,7 +53,8 @@ static void _null_term(char *str) } } -static int _job_modify(uint32_t jobid, char *bank_ptr, char *part_name_ptr, +static int _job_modify(uint32_t jobid, char *bank_ptr, + uint32_t new_node_cnt, char *part_name_ptr, uint32_t new_time_limit) { struct job_record *job_ptr; @@ -71,18 +72,20 @@ static int _job_modify(uint32_t jobid, char *bank_ptr, char *part_name_ptr, if (new_time_limit) { time_t old_time = job_ptr->time_limit; job_ptr->time_limit = new_time_limit; - info("wiki: change job %d time_limit to %u", + info("wiki: change job %u time_limit to %u", jobid, new_time_limit); /* Update end_time based upon change * to preserve suspend time info */ job_ptr->end_time = job_ptr->end_time + ((job_ptr->time_limit - old_time) * 60); + last_job_update = time(NULL); } if (bank_ptr) { - info("wiki: change job %d bank %s", jobid, bank_ptr); + info("wiki: change job %u bank %s", jobid, bank_ptr); xfree(job_ptr->account); job_ptr->account = xstrdup(bank_ptr); + last_job_update = time(NULL); } if (part_name_ptr) { @@ -93,22 +96,38 @@ static int _job_modify(uint32_t jobid, char *bank_ptr, char *part_name_ptr, part_name_ptr); return ESLURM_INVALID_PARTITION_NAME; } - info("wiki: change job %d partition %s", + info("wiki: change job %u partition %s", jobid, part_name_ptr); strncpy(job_ptr->partition, part_name_ptr, MAX_SLURM_NAME); job_ptr->part_ptr = part_ptr; + last_job_update = time(NULL); + } + + if (new_node_cnt) { + if (IS_JOB_PENDING(job_ptr) && job_ptr->details) { + job_ptr->details->min_nodes = new_node_cnt; + if (job_ptr->details->max_nodes + && (job_ptr->details->max_nodes < new_node_cnt)) + job_ptr->details->max_nodes = new_node_cnt; + info("wiki: change job %u min_nodes to %u", + jobid, new_node_cnt); + last_job_update = time(NULL); + } else { + error("wiki: MODIFYJOB node count of non-pending " + "job %u", jobid); + return ESLURM_DISABLED; + } } - last_job_update = time(NULL); return SLURM_SUCCESS; } /* RET 0 on success, -1 on failure */ extern int job_modify_wiki(char *cmd_ptr, int *err_code, char **err_msg) { - char *arg_ptr, *bank_ptr, *part_ptr, *time_ptr, *tmp_char; + char *arg_ptr, *bank_ptr, *nodes_ptr, *part_ptr, *time_ptr, *tmp_char; int slurm_rc; - uint32_t jobid, new_time_limit = 0; + uint32_t jobid, new_node_cnt = 0, new_time_limit = 0; static char reply_msg[128]; /* Locks: write job, read node and partition info */ slurmctld_lock_t job_write_lock = { @@ -128,13 +147,18 @@ extern int job_modify_wiki(char *cmd_ptr, int *err_code, char **err_msg) error("wiki: MODIFYJOB has invalid jobid"); return -1; } - bank_ptr = strstr(cmd_ptr, "BANK="); - part_ptr = strstr(cmd_ptr, "PARTITION="); - time_ptr = strstr(cmd_ptr, "TIMELIMIT="); + bank_ptr = strstr(cmd_ptr, "BANK="); + nodes_ptr = strstr(cmd_ptr, "NODES="); + part_ptr = strstr(cmd_ptr, "PARTITION="); + time_ptr = strstr(cmd_ptr, "TIMELIMIT="); if (bank_ptr) { bank_ptr += 5; _null_term(bank_ptr); } + if (nodes_ptr) { + nodes_ptr += 6; + new_node_cnt = strtoul(nodes_ptr, NULL, 10); + } if (part_ptr) { part_ptr += 10; _null_term(part_ptr); @@ -145,7 +169,8 @@ extern int job_modify_wiki(char *cmd_ptr, int *err_code, char **err_msg) } lock_slurmctld(job_write_lock); - slurm_rc = _job_modify(jobid, bank_ptr, part_ptr, new_time_limit); + slurm_rc = _job_modify(jobid, bank_ptr, new_node_cnt, part_ptr, + new_time_limit); unlock_slurmctld(job_write_lock); if (slurm_rc != SLURM_SUCCESS) { *err_code = -700; diff --git a/testsuite/expect/test7.7.prog.c b/testsuite/expect/test7.7.prog.c index 3baffc99764..98179c7b4ed 100644 --- a/testsuite/expect/test7.7.prog.c +++ b/testsuite/expect/test7.7.prog.c @@ -1,7 +1,7 @@ /*****************************************************************************\ * test7.7.prog.c - Test of sched/wiki2 plugin ***************************************************************************** - * Copyright (C) 2006 The Regents of the University of California. + * Copyright (C) 2006-2007 The Regents of the University of California. * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). * Written by Morris Jette <jette1@llnl.gov> * UCRL-CODE-226842. @@ -328,7 +328,8 @@ static void _modify_job(long my_job_id) snprintf(out_msg, sizeof(out_msg), "TS=%u AUTH=root DT=CMD=MODIFYJOB ARG=%ld " - /* PARTITION=pdebug" */ + /* "PARTITION=pdebug " */ + /* "NODES=2 " */ "TIMELIMIT=10 BANK=test_bank", (uint32_t) now, my_job_id); _xmit(out_msg); @@ -398,11 +399,12 @@ int main(int argc, char * argv[]) _get_jobs(); _get_nodes(); _job_will_run(job_id); + _modify_job(job_id); + _get_jobs(); _start_job(job_id); _get_jobs(); _suspend_job(job_id); _resume_job(job_id); - _modify_job(job_id); _signal_job(job_id); if (e_port) _event_mgr(); -- GitLab