Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plugin: add project information to Association information in plugin #434

Merged
merged 6 commits into from
Mar 27, 2024

Conversation

cmoussa1
Copy link
Member

Background

flux-accounting has the ability to define and list projects for associations in the database, but the plugin does not know about or interact with them. Eventually, the plugin will need to support associating jobs with projects. This is the first step to getting there.


This PR looks to start the process of adding project support to the priority plugin by just adding project information to the flux-accounting information that gets sent from the database to the plugin. Each Association object now has two new member fields: projects and def_project, fields to store their list of projects and their default project, respectively. This info, along with the list of all registered projects, is sent and unpacked and stored in the plugin. At the moment, it is not utilized anywhere in the plugin, it is simply just unpacked and added to each Association object. Future PRs will look to integrate actual support for associating jobs with projects.

The other piece of this PR is to add a helper function to accounting.cpp to help validate projects for a given association. The plan with this function is to use it when validating a job that charges a certain project. Unit tests are also added for this helper function.

@cmoussa1 cmoussa1 added new feature new feature plugin related to the multi-factor priority plugin labels Mar 20, 2024
@cmoussa1 cmoussa1 changed the title [WIP] plugin: add project information to Association information in plugin plugin: add project information to Association information in plugin Mar 21, 2024
@cmoussa1 cmoussa1 requested a review from jameshcorbett March 21, 2024 15:07
@cmoussa1 cmoussa1 marked this pull request as ready for review March 21, 2024 15:07
Copy link
Member

@jameshcorbett jameshcorbett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really know how projects are supposed to work but these changes look reasonable.

|| flux_jobtap_service_register (p, "rec_q_update", rec_q_cb, p) < 0)
|| flux_jobtap_service_register (p, "rec_q_update", rec_q_cb, p)
|| flux_jobtap_service_register (p, "rec_proj_update", rec_proj_cb, p)
< 0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the < 0 check only for the last one in this || chain?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, I guess I forgot to include a < 0 check for the other calls here. Thanks for catching this! I added another commit to this PR that adds checks for all of the flux_jobtap_service_register () calls here

// clear the projects vector
projects.clear ();

for (int i = 0; i < num_data; i++) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a good place for json_array_foreach?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you're right! I converted this for-loop to use json_array_foreach (). Thanks for pointing that out

@cmoussa1
Copy link
Member Author

Thanks for approving @jameshcorbett - will set MWP here shortly

Problem: The priority plugin has no way to unpack project information
from the flux-accounting database.

Add two new members to the Association class: projects and def_project,
which will store the projects an association is allowed to charge as
well as their default project.

Add an unpack of the "projects" and "def_project" columns for each
association when unpacking them in the rec_update_cb () function.

Add a new callback to unpack information from the project_table and
store it in a vector of projects to be used for project validation
and annotation.
Problem: flux-accounting does not send any information regarding
projects to the priority plugin.

Add information from the project_table and the projects column in the
association_table to the bulk update script that sends user, bank, and
queue information to the multi-factor priority plugin.
Problem: Some tests in flux-accounting's testsuite don't contain active,
project, or default project information in the payloads that get sent to
the priority plugin.

Add "active", "projects", and "def_project" key-value pairs to the fake
payloads in a number of tests in the testsuite.
Problem: There exists no way to validate a project for an association in
the priority plugin.

Add a new helper function get_project_info () which will validate a
passed-in project for an association. If the project is unknown to
flux-accounting or is an invalid one for an association to submit their
job under, an integer < 0 will be returned, otherwise 0.
Problem: There exists no unit tests for get_project_info ().

Add some unit tests.
Problem: A number of the flux_jobtap_service_register () calls in the
initialization of the plugin don't actually check the result of the
call for < 0.

Add these checks when registering the callbacks for the plugin.
Copy link

codecov bot commented Mar 27, 2024

Codecov Report

Merging #434 (45b06d9) into master (3864ed5) will increase coverage by 0.08%.
The diff coverage is 88.31%.

❗ Current head 45b06d9 differs from pull request most recent head bf90b45. Consider uploading reports for the commit bf90b45 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #434      +/-   ##
==========================================
+ Coverage   83.39%   83.47%   +0.08%     
==========================================
  Files          23       23              
  Lines        1457     1525      +68     
==========================================
+ Hits         1215     1273      +58     
- Misses        242      252      +10     
Files Coverage Δ
src/plugins/accounting.cpp 79.54% <100.00%> (+1.49%) ⬆️
src/plugins/accounting.hpp 100.00% <ø> (ø)
src/plugins/test/accounting_test01.cpp 100.00% <100.00%> (ø)
src/plugins/mf_priority.cpp 82.67% <72.72%> (-1.55%) ⬇️

@mergify mergify bot merged commit ffc9383 into flux-framework:master Mar 27, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge-when-passing new feature new feature plugin related to the multi-factor priority plugin
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants