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

[YUNIKORN-2657] Validate queue generated as part of the placement rules #891

Closed
wants to merge 11 commits into from

Conversation

manirajv06
Copy link
Contributor

@manirajv06 manirajv06 commented Jun 13, 2024

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?

  • - Feature

Todos

  • - Task

What is the Jira issue?

https://issues.apache.org/jira/browse/YUNIKORN-2657

How should this be tested?

Screenshots (if appropriate)

Questions:

  • - The licenses files need update.
  • - There is breaking changes for older versions.
  • - It needs documentation.

Copy link
Contributor

@pbacsko pbacsko left a 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}$`)
Copy link
Contributor

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.

Copy link
Contributor

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}$`)
Copy link
Contributor

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 {
Copy link
Contributor

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

Copy link
Contributor Author

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.

Comment on lines 124 to 128
childQueueName := replaceDot(fr.queue)
if err = configs.IsQueueNameValid(childQueueName); err != nil {
return "", err
}
queueName = parentName + configs.DOT + childQueueName
Copy link
Contributor

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

Copy link
Contributor Author

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.

Comment on lines 134 to 136
if err := configs.IsQueuePathValid(queueName); err != nil {
return "", err
}
Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link

codecov bot commented Jun 19, 2024

Codecov Report

Attention: Patch coverage is 95.65217% with 2 lines in your changes missing coverage. Please review.

Project coverage is 78.07%. Comparing base (5e3535c) to head (cb0e4a7).
Report is 3 commits behind head on master.

Files Patch % Lines
pkg/scheduler/placement/testrule.go 50.00% 1 Missing and 1 partial ⚠️
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.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@pbacsko pbacsko left a comment

Choose a reason for hiding this comment

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

Some smaller things.

pkg/scheduler/placement/testrule.go Show resolved Hide resolved
pkg/scheduler/objects/queue.go Outdated Show resolved Hide resolved
pkg/scheduler/objects/queue.go Outdated Show resolved Hide resolved
pkg/common/configs/configvalidator.go Outdated Show resolved Hide resolved
@manirajv06 manirajv06 requested a review from pbacsko June 20, 2024 05:26
@manirajv06
Copy link
Contributor Author

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.

@pbacsko
Copy link
Contributor

pbacsko commented Jun 20, 2024

Now it looks good, I just have a final comment left regarding coverage.

@manirajv06 manirajv06 requested a review from pbacsko June 21, 2024 09:34
Copy link
Contributor

@pbacsko pbacsko left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@wilfred-s wilfred-s left a comment

Choose a reason for hiding this comment

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

LGTM

pkg/common/configs/configvalidator.go Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants