Skip to content

Commit

Permalink
plugin: add default bank name to jobspec
Browse files Browse the repository at this point in the history
Problem: If an association submits a job under a default bank, there is
no record of what the default bank is in the jobspec or eventlog of the
job.

Add the bank name via jobspec-update under attributes.system.bank
during job.new in the case where a user is submitting a job under
their default bank.

In the case where a user submits a job before any flux-accounting info
is sent to the plugin, their job entry will be associated with the
special "DNE" bank until their information is updated.

In this case, once the information is updated and the submitted
job is once again going through job.state.priority, add the
jobspec-update call inside the if-else branch where the bank_info
struct for the job is being updated.
  • Loading branch information
cmoussa1 committed Sep 12, 2023
1 parent 89b4c41 commit a24b174
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions src/plugins/mf_priority.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,34 @@ static json_t *user_to_json (
}


/*
* Update the jobspec with the default bank the association used to
* submit their job under.
*/
static int update_jobspec_bank (flux_plugin_t *p, int userid)
{
char *bank = NULL;
std::map<int, std::map<std::string, struct bank_info>>::iterator it;

it = users.find (userid);
if (it == users.end ()) {
return -1;
}

// look up default bank
bank = const_cast<char*> (users_def_bank[userid].c_str ());

// post jobspec-update event
if (flux_jobtap_jobspec_update_pack (p,
"{s:s}",
"attributes.system.bank",
bank) < 0)
return -1;

return 0;
}


/******************************************************************************
* *
* Callbacks *
Expand Down Expand Up @@ -620,6 +648,17 @@ static int priority_cb (flux_plugin_t *p,
&bank_it->second,
NULL) < 0)
flux_log_error (h, "flux_jobtap_job_aux_set");

// now that we know the user/bank info associated with this job,
// we need to update jobspec with the default bank used to
// submit this job under
if (update_jobspec_bank (p, userid) < 0) {
flux_jobtap_raise_exception (p, FLUX_JOBTAP_CURRENT_JOB,
"mf_priority", 0,
"failed to update jobspec "
"with bank name");
return -1;
}
}
}

Expand Down Expand Up @@ -832,6 +871,14 @@ static int new_cb (flux_plugin_t *p,
"entry does not exist");
return -1;
}
// update jobspec with default bank
if (update_jobspec_bank (p, userid) < 0) {
flux_jobtap_raise_exception (p, FLUX_JOBTAP_CURRENT_JOB,
"mf_priority", 0,
"failed to update jobspec "
"with bank name");
return -1;
}
}

// fetch priority associated with passed-in queue (or default queue)
Expand Down

0 comments on commit a24b174

Please sign in to comment.