-
Notifications
You must be signed in to change notification settings - Fork 233
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
[YUNIKORN-2657] Validate queue generated as part of the placement rules #891
Conversation
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.
Fix lintern issues + see comment regarding the path regexp.
|
||
// A queue can be a username with the dot replaced. Most systems allow a 32 character user name. | ||
// The queue name must thus allow for at least that length with the replacement of dots. | ||
var QueuePathRegExp = regexp.MustCompile(`^[a-zA-Z0-9_.:#/@-]{1,64}$`) |
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.
Fix the comment, that is a copy-paste from QueueNameRegExp
.
The maximum length of 64 is a bit too low, not sure what's a reasonable limit here, I'd simply not validate the length of the path at all.
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.
Not sure that this will even work at all...
|
||
// A queue can be a username with the dot replaced. Most systems allow a 32 character user name. | ||
// The queue name must thus allow for at least that length with the replacement of dots. | ||
var QueuePathRegExp = regexp.MustCompile(`^[a-zA-Z0-9_.:#/@-]{1,64}$`) |
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.
Not sure that this will even work at all...
return nil | ||
} | ||
|
||
func IsQueuePathValid(queuePath string) error { |
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.
Not sure how this would work as we allow dots which means the length cannot be limited as each part can be 64 characters and I could have 10, 20 or more levels in a queue.
These valid queue fails this check:
root.parent_lvl1.parent_lvl2.parent_lvl3.parent_lvl4.parent_lvl5.parent_lvl6.parent_lvl7.parent_lvl8.parent_lvl9.parent_lvl10.leaf
or
root.company_name.a-long-namespace-name.wilfred_dot_spiegelenburg
Checking each part before building the path should be enough to handle this. See further comments below
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.
Yes, length check is not required. However, I still see a need to do validate that code path because there is an option to pass the full queue path in the config. If we really want to avoid full queuePath check, we should split the string based on dot and apply queueName check itself for each part.
childQueueName := replaceDot(fr.queue) | ||
if err = configs.IsQueueNameValid(childQueueName); err != nil { | ||
return "", err | ||
} | ||
queueName = parentName + configs.DOT + childQueueName |
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.
This breaks a use case. I can set the fixed part to a partial path and not qualify it.
So I can set "prod.high" as the fixed part, not qualified. Use a parent rule of User
to finally create a queue root.wilfred.prod.high
, after this change it would create root.wilfred.prod_dot_high
The fixed part compliance for all parts of the possible unqualified path should be added to the initialise()
code
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.
Yes, we should not replace dot in this rule. https://issues.apache.org/jira/browse/YUNIKORN-2660 has been filed to make the changes like you explained.
if err := configs.IsQueuePathValid(queueName); err != nil { | ||
return "", err | ||
} |
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.
If each part is valid the path must be valid. We should have checked each part before we get to the final queue path assembly.
At this point we cannot distinguish anymore between valid and invalid .
dot characters so it adds nothing.
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.
Did not repeat the comment for every rule this was part of.
02eece2
to
1faac3c
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #891 +/- ##
==========================================
+ Coverage 78.01% 78.07% +0.05%
==========================================
Files 97 97
Lines 12119 12150 +31
==========================================
+ Hits 9455 9486 +31
Misses 2354 2354
Partials 310 310 ☔ View full report in Codecov by Sentry. |
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.
Some smaller things.
Moved queueName checks to initialise block for fixed rule so that https://issues.apache.org/jira/browse/YUNIKORN-2660 also have been taken care of. |
Now it looks good, I just have a final comment left regarding coverage. |
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.
LGTM
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.
LGTM
What is this PR for?
Queue name being generated as part of the various placement rule should follow similar validation checks already being carried out for queuename coming through config.
What type of PR is it?
Todos
What is the Jira issue?
https://issues.apache.org/jira/browse/YUNIKORN-2657
How should this be tested?
Screenshots (if appropriate)
Questions: