diff --git a/src/plugins/job_submit/defaults/job_submit_defaults.c b/src/plugins/job_submit/defaults/job_submit_defaults.c index 0fe982a7f8ca537518e82b313103ccdd925c6cdb..ed1273bffa3e48ce7365d9abc04a918b05beefe9 100644 --- a/src/plugins/job_submit/defaults/job_submit_defaults.c +++ b/src/plugins/job_submit/defaults/job_submit_defaults.c @@ -67,6 +67,8 @@ #include "src/common/slurm_xlator.h" #include "src/slurmctld/slurmctld.h" +#define MIN_ACCTG_FREQUENCY 30 + /* * These variables are required by the generic plugin interface. If they * are not found in the plugin, the plugin loader will ignore it. @@ -98,15 +100,30 @@ const char plugin_type[] = "job_submit/defaults"; const uint32_t plugin_version = 100; const uint32_t min_plug_version = 100; +/* This example code will prevent users from setting an accounting frequency + * of less than 30 seconds in order to insure more precise accounting. + * Also remove any QOS value set by the user in order to use the default value + * from the database. */ extern int job_submit(struct job_descriptor *job_desc) { - info("in job_submit/defaults, job_submit"); + if (job_desc->acctg_freq < MIN_ACCTG_FREQUENCY) { + info("Changing accounting frequency of submitted from %u to %u", + job_desc->acctg_freq, MIN_ACCTG_FREQUENCY); + job_desc->acctg_freq = MIN_ACCTG_FREQUENCY; + } + + if (job_desc->qos) { + info("Clearing QOS (%s) from submitted job", job_desc->qos); + xfree(job_desc->qos); + } + return SLURM_SUCCESS; } +/* This example code will prevent users from setting an accounting frequency + * of less than 30 seconds in order to insure more precise accounting. */ extern int job_modify(struct job_descriptor *job_desc, struct job_record *job_ptr) { - info("in job_submit/defaults, job_modify"); return SLURM_SUCCESS; } diff --git a/src/plugins/job_submit/logging/job_submit_logging.c b/src/plugins/job_submit/logging/job_submit_logging.c index 537faeaca1c757bcb18bbab7642b1534418487a9..b15ece6d815ee13ac6c3bb318699670627e4b055 100644 --- a/src/plugins/job_submit/logging/job_submit_logging.c +++ b/src/plugins/job_submit/logging/job_submit_logging.c @@ -101,13 +101,29 @@ const uint32_t min_plug_version = 100; extern int job_submit(struct job_descriptor *job_desc) { - info("in job_submit/logging, job_submit"); + /* Log select fields from a job submit request. See slurm/slurm.h + * for information about additional fields in struct job_descriptor. + * Note that default values for most numbers is NO_VAL */ + info("Job submit request: account:%s begin_time:%u dependency:%s " + "name:%s partition:%s qos:%s time_limit:%u user_id:%u", + job_desc->account, job_desc->begin_time, job_desc->dependency, + job_desc->name, job_desc->partition, job_desc->qos, + job_desc->time_limit, job_desc->user_id); + return SLURM_SUCCESS; } extern int job_modify(struct job_descriptor *job_desc, struct job_record *job_ptr) { - info("in job_submit/logging, job_modify"); + /* Log select fields from a job modify request. See slurm/slurm.h + * for information about additional fields in struct job_descriptor. + * Note that default values for most numbers is NO_VAL */ + info("Job modify request: account:%s begin_time:%u dependency:%s " + "job_id:%u name:%s partition:%s qos:%s time_limit:%u", + job_desc->account, job_desc->begin_time, job_desc->dependency, + job_desc->job_id, job_desc->name, job_desc->partition, + job_desc->qos, job_desc->time_limit); + return SLURM_SUCCESS; } diff --git a/src/plugins/job_submit/partition/job_submit_partition.c b/src/plugins/job_submit/partition/job_submit_partition.c index f7beb196a2256d94aaea5aed8361854c881c03ef..822ccc378eda3ac4c8181a6a21467fd550c0a8cf 100644 --- a/src/plugins/job_submit/partition/job_submit_partition.c +++ b/src/plugins/job_submit/partition/job_submit_partition.c @@ -99,15 +99,64 @@ const char plugin_type[] = "job_submit/partition"; const uint32_t plugin_version = 100; const uint32_t min_plug_version = 100; +/* Test if this user can run jobs in the selected partition based upon + * the partition's AllowGroups parameter. */ +static bool _user_access(uid_t run_uid, struct part_record *part_ptr) +{ + int i; + + if ((run_uid == 0) || (run_uid == getuid())) + return true; /* Superuser can run anywhere */ + + if (!part_ptr->allow_uids) + return true; /* AllowGroups=ALL */ + + for (i=0; part_ptr->allow_uids[i]; i++) { + if (part_ptr->allow_uids[i] == run_uid) + return true; /* User in AllowGroups */ + } + return false; /* User not in AllowGroups */ +} + +/* This exampe code will set a job's default partition to the highest + * priority partition that is available to this user. This is only an + * example and tremendous flexibility is available. */ extern int job_submit(struct job_descriptor *job_desc) { - info("in job_submit/partition, job_submit"); + ListIterator part_iterator; + struct part_record *part_ptr; + struct part_record *top_prio_part = NULL; + + if (job_desc->partition) /* job already specified partition */ + return SLURM_SUCCESS; + + part_iterator = list_iterator_create(part_list); + if (!part_iterator) + fatal("list_iterator_create malloc"); + while ((part_ptr = (struct part_record *) list_next(part_iterator))) { + if (!(part_ptr->state_up & PARTITION_SUBMIT)) + continue; /* nobody can submit jobs here */ + if (!_user_access(job_desc->user_id, part_ptr)) + continue; /* AllowGroups prevents use */ + if (!top_prio_part || + (top_prio_part->priority < part_ptr->priority)) { + /* Found higher priority partition */ + top_prio_part = part_ptr; + } + } + list_iterator_destroy(part_iterator); + + if (top_prio_part) { + info("Setting partition of submitted job to %s", + top_prio_part->name); + job_desc->partition = xstrdup(top_prio_part->name); + } + return SLURM_SUCCESS; } extern int job_modify(struct job_descriptor *job_desc, struct job_record *job_ptr) { - info("in job_submit/partition, job_modify"); return SLURM_SUCCESS; }