-
Notifications
You must be signed in to change notification settings - Fork 2
Multiple scoped HRQs with the same name #24
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
Conversation
internal/hrq/utils/scopedhrq.go
Outdated
| ) | ||
|
|
||
| const ( | ||
| maxRQNameLength = 253 |
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.
How about using validation.DNS1123SubdomainMaxLength in k8s.io/apimachinery/pkg/util/validation instead of the magic number?
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.
Fixed in e3589c1
internal/hrq/utils/scopedhrq.go
Outdated
| metadata.SetLabel(rq, hrqNameLabel, hrqName) | ||
| } | ||
|
|
||
| func truncate(s string, n int) string { |
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.
n should be positive numbers to avoid panic. Using uint or adding validation?
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.
Fixed in 78a2633
…23SubdomainMaxLength for improved name length handling
utam0k
left a comment
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!
Previously, there was an issue where the names of scoped RQs created from scoped HRQs could conflict. This PR fixes that problem.
Problem
In the previous implementation, the name of a scoped RQ was just a prefixed version of the scoped HRQ name. As a result, if a parent namespace and a child namespace had scoped HRQs with the same name, it would try to create RQs with the same name in the child namespace and fail.
Solution
This PR changes the RQ naming to include the namespace name and an MD5 hash of
hrqNamespace/hrqName. However, since this can make the name exceed the length limit, the name is truncated appropriately when it's too long.