diff --git a/src/scontrol/scontrol.c b/src/scontrol/scontrol.c index 9a2c3186ec0c9b202626684a43e2e3b8b264ff5c..8fbfac46c783518c62d4b4955105440b74d93de3 100644 --- a/src/scontrol/scontrol.c +++ b/src/scontrol/scontrol.c @@ -3,7 +3,7 @@ * provides interface to read, write, update, and configurations. ***************************************************************************** * Copyright (C) 2002-2007 The Regents of the University of California. - * Copyright (C) 2008 Lawrence Livermore National Security. + * Copyright (C) 2008-2009 Lawrence Livermore National Security. * Portions Copyright (C) 2008 Vijay Ramasubramanian. * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). * Written by Morris Jette <jette1@llnl.gov> diff --git a/src/scontrol/update_part.c b/src/scontrol/update_part.c index 38e77a56e388d1382be536bdbdca18a2070fcd1c..5e2cfea88061eb4db085b0fec79ef8bd8cc3e4b5 100644 --- a/src/scontrol/update_part.c +++ b/src/scontrol/update_part.c @@ -211,9 +211,6 @@ scontrol_update_part (int argc, char *argv[]) slurm_init_part_desc_msg ( &part_msg ); scontrol_parse_part_options (argc, argv, &update_cnt, &part_msg); - if (exit_code != 0) - return 0; - if (update_cnt == 0) { exit_code = 1; error("No changes specified"); @@ -246,8 +243,11 @@ scontrol_create_part (int argc, char *argv[]) slurm_init_part_desc_msg ( &part_msg ); scontrol_parse_part_options (argc, argv, &update_cnt, &part_msg); - if (exit_code != 0) + if (update_cnt == 0) { + exit_code = 1; + error("No parameters specified"); return 0; + } if (slurm_create_partition(&part_msg)) { exit_code = 1; diff --git a/src/slurmctld/partition_mgr.c b/src/slurmctld/partition_mgr.c index fd8a2601c30229d7613db9596d0152f19f0aceb8..f0b32746bb38aa214118eba2f6eb1a0d554f37f9 100644 --- a/src/slurmctld/partition_mgr.c +++ b/src/slurmctld/partition_mgr.c @@ -798,31 +798,44 @@ void pack_part(struct part_record *part_ptr, Buf buffer) /* - * update_part - update a partition's configuration data + * update_part - create or update a partition's configuration data * IN part_desc - description of partition changes + * IN create_flag - create a new partition * RET 0 or an error code * global: part_list - list of partition entries * last_part_update - update time of partition records */ -int update_part(update_part_msg_t * part_desc) +extern int update_part (update_part_msg_t * part_desc, bool create_flag) { int error_code; struct part_record *part_ptr; if (part_desc->name == NULL) { - error("update_part: invalid partition name, NULL"); + info("update_part: invalid partition name, NULL"); return ESLURM_INVALID_PARTITION_NAME; } error_code = SLURM_SUCCESS; - part_ptr = list_find_first(part_list, &list_find_part, part_desc->name); + part_ptr = list_find_first(part_list, &list_find_part, + part_desc->name); - if (part_ptr == NULL) { - info("update_part: partition %s does not exist, " - "being created", part_desc->name); + if (create_flag) { + if (part_ptr) { + verbose("Duplicate partition name for create (%s)", + part_desc->name); + return ESLURM_INVALID_PARTITION_NAME; + } + info("update_part: partition %s being created", + part_desc->name); part_ptr = create_part_record(); xfree(part_ptr->name); part_ptr->name = xstrdup(part_desc->name); + } else { + if (!part_ptr) { + verbose("Update for partition not found (%s)", + part_desc->name); + return ESLURM_INVALID_PARTITION_NAME; + } } last_part_update = time(NULL); diff --git a/src/slurmctld/proc_req.c b/src/slurmctld/proc_req.c index ab148171ae4d63e2027067b2486c048b5427e924..3bccd28d4b6191b2401d85da0ae4bd6ce7dee93d 100644 --- a/src/slurmctld/proc_req.c +++ b/src/slurmctld/proc_req.c @@ -2271,9 +2271,13 @@ static void _slurm_rpc_update_partition(slurm_msg_t * msg) error_code = select_g_update_block(part_desc_ptr); else if(part_desc_ptr->root_only == (uint16_t)INFINITE) error_code = select_g_update_sub_node(part_desc_ptr); - else { + else if (msg->msg_type == REQUEST_CREATE_PARTITION) { + lock_slurmctld(part_write_lock); + error_code = update_part(part_desc_ptr, true); + unlock_slurmctld(part_write_lock); + } else { lock_slurmctld(part_write_lock); - error_code = update_part(part_desc_ptr); + error_code = update_part(part_desc_ptr, false); unlock_slurmctld(part_write_lock); } END_TIMER2("_slurm_rpc_update_partition"); diff --git a/src/slurmctld/slurmctld.h b/src/slurmctld/slurmctld.h index b20d729d9d64f0d505c8ec33875a135075aca69b..72e71a3a22391a1b8845321e0e24ad81cbf02bda 100644 --- a/src/slurmctld/slurmctld.h +++ b/src/slurmctld/slurmctld.h @@ -1512,13 +1512,14 @@ extern void update_logging(void); extern int update_node ( update_node_msg_t * update_node_msg ) ; /* - * update_part - update a partition's configuration data + * update_part - create or update a partition's configuration data * IN part_desc - description of partition changes + * IN create_flag - create a new partition * RET 0 or an error code * global: part_list - list of partition entries * last_part_update - update time of partition records */ -extern int update_part (update_part_msg_t * part_desc ); +extern int update_part (update_part_msg_t * part_desc, bool create_flag); /* * validate_group - validate that the submit uid is authorized to run in diff --git a/testsuite/expect/README b/testsuite/expect/README index 6ed40b2d2a3e4b9de36bd53960af2ff48ff08c63..c5ef374e5ff36aeac7e3d34a09a21f4c8ba89b81 100644 --- a/testsuite/expect/README +++ b/testsuite/expect/README @@ -1,6 +1,6 @@ ############################################################################ -# Copyright (C) 2008 Lawrence Livermore National Security. # Copyright (C) 2002-2007 The Regents of the University of California. +# Copyright (C) 2008-2009 Lawrence Livermore National Security. # Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). # Written by Morris Jette <jette1@llnl.gov> # Additionals by Joseph Donaghy <donaghy1@llnl.gov> diff --git a/testsuite/expect/test3.5 b/testsuite/expect/test3.5 index 401d7352b1ebe123ac7ee875b2b22ae7ef8a32a9..90a7ee6a55d65ec993eae8d9876086613f5407cd 100755 --- a/testsuite/expect/test3.5 +++ b/testsuite/expect/test3.5 @@ -107,7 +107,7 @@ if {[string compare $def_node ""] == 0} { # # Create a new partition # -spawn $scontrol update PartitionName=$part_name Nodes=$def_node +spawn $scontrol create PartitionName=$part_name Nodes=$def_node expect { -re "slurm_update error: Invalid user" { send_user "\nWARNING: user not authorized to create partition\n"