Skip to content

Commit

Permalink
Merge pull request #430 from cmoussa1/move.add-missing-bank-info
Browse files Browse the repository at this point in the history
plugin: improve `add_missing_bank_info ()`
  • Loading branch information
mergify[bot] authored Mar 15, 2024
2 parents ad1d92b + 8ff3c85 commit e65091c
Showing 1 changed file with 31 additions and 27 deletions.
58 changes: 31 additions & 27 deletions src/plugins/mf_priority.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,35 @@ static int update_jobspec_bank (flux_plugin_t *p, int userid)
}


/*
* Create a special Association object for an association's job while the
* plugin waits for flux-accounting data to be loaded.
*/
static void add_special_association (flux_plugin_t *p, flux_t *h, int userid)
{
Association *a;

a = &users[userid]["DNE"];
users_def_bank[userid] = "DNE";

a->bank_name = "DNE";
a->fairshare = 0.1;
a->max_run_jobs = BANK_INFO_MISSING;
a->cur_run_jobs = 0;
a->max_active_jobs = 1000;
a->cur_active_jobs = 0;
a->active = 1;
a->held_jobs = std::vector<long int>();

if (flux_jobtap_job_aux_set (p,
FLUX_JOBTAP_CURRENT_JOB,
"mf_priority:bank_info",
a,
NULL) < 0)
flux_log_error (h, "flux_jobtap_job_aux_set");
}


/******************************************************************************
* *
* Callbacks *
Expand Down Expand Up @@ -436,31 +465,6 @@ static int priority_cb (flux_plugin_t *p,
}


static void add_missing_bank_info (flux_plugin_t *p, flux_t *h, int userid)
{
Association *b;

b = &users[userid]["DNE"];
users_def_bank[userid] = "DNE";

b->bank_name = "DNE";
b->fairshare = 0.1;
b->max_run_jobs = BANK_INFO_MISSING;
b->cur_run_jobs = 0;
b->max_active_jobs = 1000;
b->cur_active_jobs = 0;
b->active = 1;
b->held_jobs = std::vector<long int>();

if (flux_jobtap_job_aux_set (p,
FLUX_JOBTAP_CURRENT_JOB,
"mf_priority:bank_info",
b,
NULL) < 0)
flux_log_error (h, "flux_jobtap_job_aux_set");
}


/*
* Perform basic validation of a user/bank's submitted job. If a bank or
* queue is specified on submission, ensure that the user is allowed to
Expand Down Expand Up @@ -515,7 +519,7 @@ static int validate_cb (flux_plugin_t *p,
bool only_dne_data = check_map_for_dne_only (users, users_def_bank);

if (users.empty () || only_dne_data) {
add_missing_bank_info (p, h, userid);
add_special_association (p, h, userid);
return 0;
} else {
return flux_jobtap_reject_job (p,
Expand Down Expand Up @@ -595,7 +599,7 @@ static int new_cb (flux_plugin_t *p,
if (b == nullptr) {
// the association could not be found in internal map, so create a
// special Association object that will hold the job in PRIORITY
add_missing_bank_info (p, h, userid);
add_special_association (p, h, userid);
return 0;
}

Expand Down

0 comments on commit e65091c

Please sign in to comment.