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 callback specific for validating an updated queue #399

Merged
merged 3 commits into from
Nov 6, 2023

Conversation

cmoussa1
Copy link
Member

Problem

The multi-factor priority plugin uses the same callback for both validating an updated queue and for actually updating the queue on a user/bank's job. This will be an issue when additional "updateable" attributes are added to the plugin, such as banks.


This PR adds a new callback to the plugin, update_queue_cb (), which is responsible for validating an updated queue and will reject the update if it is not valid for the user/bank. It assigns this callback to the "job.update.attributes.system.queue" topic string.

As a result of adding the new update_queue_cb () callback, the job_updated () callback is also changed to unpack the "updates" JSON object when unpacking arguments and see if there is an update for the queue attribute. It checks its contents and applies its update to the job that requested the queue update.

Lastly, I've added comments at the top of both functions with a short description (mostly so I don't forget how this flow of updating job attributes works in the future 😆).

@cmoussa1 cmoussa1 added improvement Upgrades to an already existing feature plugin related to the multi-factor priority plugin labels Oct 12, 2023
Copy link
Contributor

@grondo grondo left a comment

Choose a reason for hiding this comment

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

I found one possible issue inline. I'm actually a little mystified why tests did not fail with this change (it looks like the bank can never be detected during a queue update). So possibly I'm missing something here...

"{s:i, s:s, s?s}",
"userid", &userid,
"value", &queue,
"attributes.system.bank", &bank) < 0)
Copy link
Contributor

Choose a reason for hiding this comment

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

I do not think there will be a key called attributes.system.bank in the args to the job.update.attributes.system.queue callback.

Do you mean to be unpacking the bank from the jobspec? Then you have to unpack like in line 1092 above, e.g. something like:

    flux_plugin_arg_unpack (args,
                            FLUX_PLUGIN_ARG_IN,
                            "{s{s{s{s?s, s?s}}}}",
                            "jobspec", "attributes", "system", "bank", &bank);

However, I'm curious why tests are passing with this code, so maybe you saw different behavior here?

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! Sorry about that. Yes, I do mean to be unpacking the bank from the jobspec - I think I thought I could shorthand the traditional way of unpacking it from jobspec, just like you suggested above. Since the tests were passing, I figured this was okay too...

Perhaps the reason it passes with this is because in this set of tests, the user is submitting their job under a default bank, and thus flux_jobtap_jobspec_update_pack () is being called to add the bank to the main eventlog?

Either way, I can fix this to unpack it like how I always have.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe also look into adding a test that exercises this code when the user sets a non-default bank? Just in case :-)

Copy link
Member Author

@cmoussa1 cmoussa1 Oct 12, 2023

Choose a reason for hiding this comment

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

sure thing! i can add another set of tests to t1030 that basically repeats the same workflow, but under a non-default bank. i'll push up a commit to this branch if that's okay.

EDIT: default --> non-default

Copy link
Member Author

Choose a reason for hiding this comment

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

btw, i was curious, so i went back and tried submitting a job under a non-default bank and using what i had originally proposed in the callback for job.update.attributes.system.queue:

                                "{s:i, s:s, s?s}",
                                "userid", &userid,
                                "value", &queue,
                                "attributes.system.bank", &bank) < 0)

and the tests failed. So thanks for catching that!

Copy link
Contributor

@grondo grondo left a comment

Choose a reason for hiding this comment

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

LGTM!

@cmoussa1
Copy link
Member Author

cmoussa1 commented Nov 6, 2023

Thanks! Setting MWP here

Problem: The multi-factor priority plugin uses the same callback for
validating an updated queue and for actually updating the queue on a
user/bank's job. This will be an issue when additional "updateable"
attributes are added to the plugin, such as banks.

Add a new callback to the plugin, update_queue_cb (), that is
responsible for validating an updated queue and rejects the update
if it is not valid for the user/bank. Assign the callback for the
"job.update.attributes.system.queue" topic string.

As a result of adding the new update_queue_cb () callback, change the
job_updated () callback to unpack the "updates" JSON object when
unpacking arguments and see if there is an update for the queue
attribute. Check its contents for NULL before applying its update to
the job that requested the queue update.

Add a comment at the top of the job_updated () function with a
description of what it does.
Problem: The priority plugin prefixes the error message for an invalid
queue with "mf_priority:", which is not included in the "grep" check in
t1030-mf-priority-update-queue.t.

Update the error message to include this prefix.
Problem: t1030-mf-priority-update-queue.t has no tests that test
submitting a pending job under a non-default bank and changing its
queue.

Add some tests that do this.
@cmoussa1 cmoussa1 force-pushed the plugin.queue.updates branch from 4f95abc to a14133a Compare November 6, 2023 16:19
Copy link

codecov bot commented Nov 6, 2023

Codecov Report

Merging #399 (85ce780) into master (9fef06e) will decrease coverage by 0.05%.
The diff coverage is 77.27%.

❗ Current head 85ce780 differs from pull request most recent head a14133a. Consider uploading reports for the commit a14133a to get more accurate results

@@            Coverage Diff             @@
##           master     #399      +/-   ##
==========================================
- Coverage   81.04%   81.00%   -0.05%     
==========================================
  Files          20       20              
  Lines        1419     1437      +18     
==========================================
+ Hits         1150     1164      +14     
- Misses        269      273       +4     
Files Coverage Δ
src/plugins/mf_priority.cpp 78.72% <77.27%> (-0.04%) ⬇️

@mergify mergify bot merged commit 1a84215 into flux-framework:master Nov 6, 2023
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement Upgrades to an already existing feature merge-when-passing plugin related to the multi-factor priority plugin
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants