diff --git a/src/plugins/mf_priority.cpp b/src/plugins/mf_priority.cpp index 44b8724ff..1e5412f7e 100644 --- a/src/plugins/mf_priority.cpp +++ b/src/plugins/mf_priority.cpp @@ -305,19 +305,21 @@ static int validate_cb (flux_plugin_t *p, { int userid; char *bank = NULL; + char *queue = NULL; int max_run_jobs, cur_active_jobs, max_active_jobs = 0; double fairshare = 0.0; std::map>::iterator it; std::map::iterator bank_it; + std::map::iterator q_it; flux_t *h = flux_jobtap_get_flux (p); if (flux_plugin_arg_unpack (args, FLUX_PLUGIN_ARG_IN, - "{s:i, s{s{s{s?s}}}}", + "{s:i, s{s{s{s?s, s?s}}}}", "userid", &userid, "jobspec", "attributes", "system", - "bank", &bank) < 0) { + "bank", &bank, "queue", &queue) < 0) { return flux_jobtap_reject_job (p, args, "unable to unpack bank arg"); } @@ -342,6 +344,35 @@ static int validate_cb (flux_plugin_t *p, "user/default bank entry does not exist"); } + // make sure that if a queue is passed in, it 1) exists, and 2) is a valid + // queue for the user to run jobs in + if (queue != NULL) { + // check #1) the queue passed in exists in the queues map + q_it = queues.find (queue); + if (q_it == queues.end ()) + return flux_jobtap_reject_job (p, args, "Queue does not exist"); + + // check #2) the queue passed in is a valid option to pass for user + std::vector::iterator vect_it; + vect_it = std::find (bank_it->second.queues.begin (), + bank_it->second.queues.end (), queue); + + if (vect_it == bank_it->second.queues.end ()) + return flux_jobtap_reject_job (p, args, "Queue not valid for user"); + else + // add priority associated with the passed in queue to bank_info + bank_it->second.queue_factor = queues[queue].priority; + } else { + // no queue was specified, so use default queue and associated priority + q_it = queues.find ("default"); + + if (q_it == queues.end ()) + return flux_jobtap_reject_job (p, args, "No default queue exists"); + else + // add priority associated with the passed in queue to bank_info + bank_it->second.queue_factor = queues["default"].priority; + } + max_run_jobs = bank_it->second.max_run_jobs; fairshare = bank_it->second.fairshare; cur_active_jobs = bank_it->second.cur_active_jobs;