diff --git a/src/cmd/flux-account-priority-update.py b/src/cmd/flux-account-priority-update.py index 5f605104..fba29cbc 100755 --- a/src/cmd/flux-account-priority-update.py +++ b/src/cmd/flux-account-priority-update.py @@ -78,7 +78,7 @@ def bulk_update(path): for row in cur.execute( """SELECT userid, bank, default_bank, fairshare, max_running_jobs, max_active_jobs, - queues, active, projects, default_project, max_nodes + queues, active, projects, default_project, max_nodes, max_cores FROM association_table""" ): # create a JSON payload with the results of the query @@ -94,6 +94,7 @@ def bulk_update(path): "projects": str(row[8]), "def_project": str(row[9]), "max_nodes": int(row[10]), + "max_cores": int(row[11]), } bulk_user_data.append(single_user_data) @@ -159,6 +160,7 @@ def send_instance_owner_info(): "projects": "*", "def_project": "*", "max_nodes": 1000000, + "max_cores": 1000000, } flux.Flux().rpc( diff --git a/src/plugins/accounting.cpp b/src/plugins/accounting.cpp index 7a02638c..7b463a74 100644 --- a/src/plugins/accounting.cpp +++ b/src/plugins/accounting.cpp @@ -85,8 +85,8 @@ json_t* Association::to_json () const } // 'o' steals the reference for both held_job_ids and user_queues - json_t *u = json_pack ("{s:s, s:f, s:i, s:i, s:i, s:i," - " s:o, s:o, s:i, s:o, s:s, s:i, s:i}", + json_t *u = json_pack ("{s:s, s:f, s:i, s:i, s:i, s:i, s:o," + " s:o, s:i, s:o, s:s, s:i, s:i, s:i}", "bank_name", bank_name.c_str (), "fairshare", fairshare, "max_run_jobs", max_run_jobs, @@ -99,6 +99,7 @@ json_t* Association::to_json () const "projects", user_projects, "def_project", def_project.c_str (), "max_nodes", max_nodes, + "max_cores", max_cores, "active", active); if (!u) diff --git a/src/plugins/accounting.hpp b/src/plugins/accounting.hpp index 4cbec507..f83884db 100644 --- a/src/plugins/accounting.hpp +++ b/src/plugins/accounting.hpp @@ -45,6 +45,7 @@ class Association { std::vector projects; // list of accessible projects std::string def_project; // default project int max_nodes; // max num nodes across all running jobs + int max_cores; // max num cores across all running jobs // methods json_t* to_json () const; // convert object to JSON string diff --git a/src/plugins/mf_priority.cpp b/src/plugins/mf_priority.cpp index e1825d04..36b5853c 100644 --- a/src/plugins/mf_priority.cpp +++ b/src/plugins/mf_priority.cpp @@ -187,6 +187,7 @@ static void add_special_association (flux_plugin_t *p, flux_t *h, int userid) a->active = 1; a->held_jobs = std::vector(); a->max_nodes = INT16_MAX; + a->max_cores = INT16_MAX; if (flux_jobtap_job_aux_set (p, FLUX_JOBTAP_CURRENT_JOB, @@ -277,7 +278,7 @@ static void rec_update_cb (flux_t *h, void *arg) { char *bank, *def_bank, *assoc_queues, *assoc_projects, *def_project = NULL; - int uid, max_running_jobs, max_active_jobs, max_nodes = 0; + int uid, max_running_jobs, max_active_jobs, max_nodes, max_cores = 0; double fshare = 0.0; json_t *data, *jtemp = NULL; json_error_t error; @@ -301,7 +302,7 @@ static void rec_update_cb (flux_t *h, if (json_unpack_ex (el, &error, 0, "{s:i, s:s, s:s, s:F, s:i," - " s:i, s:s, s:i, s:s, s:s, s:i}", + " s:i, s:s, s:i, s:s, s:s, s:i, s:i}", "userid", &uid, "bank", &bank, "def_bank", &def_bank, @@ -312,7 +313,8 @@ static void rec_update_cb (flux_t *h, "active", &active, "projects", &assoc_projects, "def_project", &def_project, - "max_nodes", &max_nodes) < 0) + "max_nodes", &max_nodes, + "max_cores", &max_cores) < 0) flux_log (h, LOG_ERR, "mf_priority unpack: %s", error.text); Association *b; @@ -325,6 +327,7 @@ static void rec_update_cb (flux_t *h, b->active = active; b->def_project = def_project; b->max_nodes = max_nodes; + b->max_cores = max_cores; // split queues comma-delimited string and add it to b->queues vector b->queues.clear (); diff --git a/src/plugins/test/accounting_test01.cpp b/src/plugins/test/accounting_test01.cpp index 5d56b65d..b444b184 100644 --- a/src/plugins/test/accounting_test01.cpp +++ b/src/plugins/test/accounting_test01.cpp @@ -55,7 +55,8 @@ void add_user_to_map ( a.active, a.projects, a.def_project, - a.max_nodes + a.max_nodes, + a.max_cores }; } @@ -67,9 +68,9 @@ void initialize_map ( std::map> &users) { Association user1 = {"bank_A", 0.5, 5, 0, 7, 0, {}, - {}, 0, 1, {"*"}, "*", 2147483647}; + {}, 0, 1, {"*"}, "*", 2147483647, 2147483647}; Association user2 = {"bank_A", 0.5, 5, 0, 7, 0, {}, - {}, 0, 1, {"*"}, "*", 2147483647}; + {}, 0, 1, {"*"}, "*", 2147483647, 2147483647}; add_user_to_map (users, 1001, "bank_A", user1); users_def_bank[1001] = "bank_A"; @@ -271,7 +272,7 @@ static void test_check_map_dne_true () users_def_bank.clear (); Association tmp_user = {"DNE", 0.5, 5, 0, 7, 0, {}, - {}, 0, 1, {"*"}, "*", 2147483647}; + {}, 0, 1, {"*"}, "*", 2147483647, 2147483647}; add_user_to_map (users, 9999, "DNE", tmp_user); users_def_bank[9999] = "DNE";