-
Notifications
You must be signed in to change notification settings - Fork 41
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
policy: refactor options to allow custom #1268
base: master
Are you sure you want to change the base?
Conversation
And I know the testing and the code should be in separate commits... sigh (will fix) |
f7f1df3
to
cd87d59
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for opening this @wihobbs! I have just some preliminary questions/comments on a first pass. Apologies in advance that I'm not very familiar with the sched code at all so I could definitely be misunderstanding how this works. :-)
resource_type_t node_rt ("node"); | ||
std::shared_ptr<dfu_match_cb_t> create_match_cb (const std::string &policy_requested) | ||
{ | ||
std::string policy = policies.find (policy_requested)->second; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this .find ()
call have any sort of error checking after the lookup of policy_requested
? Maybe this is always guaranteed to find something successfully. If not, maybe you can check the contents of policy
before moving on.
if (policy == "")
// return an error?
// set matcher to something default?
// sorry that idk what the right behavior should be here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mmm good catch. It should call known_match_policy
first to see if the policy exists.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, actually, known_match_policy
is called when the config is validated in resource/modules/resource_match_opts.cpp
so it's already been validated before it gets here.
This will need additional work to support custom
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case, a comment making note that it is already validated by the time it gets to that lookup might be helpful here!
|
||
if (option_exists ("stop_on_k_matches", policy)) { | ||
ptr->set_stop_on_k_matches (parse_int_match_options ("stop_on_k_matches", policy)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this if-else
branch need an else
statement? Excuse my ignorance on this - I'm not sure if the addition of custom policies allows for something other than low
or high
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIK low and high are the only options, unless locality
or variation
are chosen.
cd87d59
to
5f03ae3
Compare
Problem: the current fluxion policy matching factory doesn't allow for customizable policies. Add a custom option and refactor existing policies to behave similarly. Add unit testing for the string parsing convenience functions.
5f03ae3
to
ba80f7b
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1268 +/- ##
======================================
Coverage 75.4% 75.5%
======================================
Files 107 108 +1
Lines 15219 15254 +35
======================================
+ Hits 11487 11520 +33
- Misses 3732 3734 +2
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just did a quick look-through, it looks reasonable to me. I think the commits could be broken up better though (as you noted already)
bool known_match_policy (const std::string &policy); | ||
|
||
const std::map<std::string, std::string> policies = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll do a deeper look over this, but first thing this should be split. Put the declaration here with extern
and the definition in the cpp file so this variable doesn't end up getting defined in all includers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be fair, that's what the old code did, but it shouldn't 😬
PR title seems truncated? |
Well, Note that this is still WIP and needs some config work and testing for the custom options. Happy to incorporate any feedback on the initial draft (and thanks to those who have already reviewed!), but it's going to stay in draft state until the code can:
|
Per discussion with Tom:
|
Problem: the current fluxion policy matching factory doesn't allow for customizable policies.
Add a custom option and refactor existing policies to behave similarly. Add unit testing for the string parsing convenience functions.
Outstanding to-do: