Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

[Core][Label scheduling 8/n]Add length and illegal letters validation to the node labels#38824

Open
larrylian wants to merge1 commit intoray-project:master
base:master
Choose a base branch
Loading
fromlarrylian:labels_scheduling_8

Conversation

larrylian
Copy link
Contributor

@larrylianlarrylian commentedAug 24, 2023
edited
Loading

Why are these changes needed?

Add length and illegal letters validation to the node labels:
The keys and values of node labels:

  1. cannot be empty and cannot exceed 127 characters
  2. must consist of letters froma-z0-9A-Z or- or_ or. or/

Why?

  1. cannot exceed 127 characters ?
    The excessive length negatively impacts performance and can cause unknown code crashes. And using a length of 127 is completely sufficient to include the information of node ID and actor ID.

  2. must consist of letters froma-z0-9A-Z or- or_ or. or/
    To avoid unknown issues caused by users inputting special characters,

Example:
image

Related issue number

#34894

Checks

  • I've signed off every commit(by using the -s flag, i.e.,git commit -s) in this PR.
  • I've runscripts/format.sh to lint the changes in this PR.
  • I've included any doc changes needed forhttps://docs.ray.io/en/master/.
    • I've added any new APIs to the API Reference. For example, if I added a
      method in Tune, I've added it indoc/source/tune/api/ under the
      corresponding.rst file.
  • I've made sure the tests are passing. Note that there might be a few flaky tests, see the recent failures athttps://flakey-tests.ray.io/
  • Testing Strategy
    • Unit tests
    • Release tests
    • This PR is not tested :(

@jjyao
Copy link
Collaborator

Why do we need to have such limitations?

@larrylian
Copy link
ContributorAuthor

larrylian commentedAug 25, 2023
edited
Loading

Why do we need to have such limitations?@jjyao

  1. Limit the length of the string to avoid crashes or performance degradation caused by excessively long string.
  2. Restrict character types to facilitate future expansion and avoid unpredictable issues caused by special characters.
  3. Like the rule of kubernetes (K8s) labels.https://kubernetes.io/docs/concepts/overview/worki
    ng-with-objects/labels/

But i see our node_id length is 56, eg:109c4a2ba1154a0959714e5b503ec475be669da3c625e482c8d2b1ed.
We should increase this max length to 96 or 128 ?

@jjyao
Copy link
Collaborator

I feel in general Ray doesn't enforce any limitations (not sure if it's a good thing or not): for example, we don't have limitations on custom resource name. So not sure what the limitations we should put on labels.

@larrylian
Copy link
ContributorAuthor

I feel in general Ray doesn't enforce any limitations (not sure if it's a good thing or not): for example, we don't have limitations on custom resource name. So not sure what the limitations we should put on labels.

I can understand your meaning. However, I think it would be better to add parameter limitations at the beginning rather than having no restrictions.
For example, if we need to add limitations later, there may be compatibility issues. If we add limitations now and later relax some of restrictions, it can ensure compatibility

@stale
Copy link

stalebot commentedOct 15, 2023

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. Thank you for your contributions.

  • If you'd like to keep this open, just leave any comment, and the stale label will be removed.

@stalestalebot added the staleThe issue is stale. It will be closed within 7 days unless there are further conversation labelOct 15, 2023
@jjyaojjyao removed the staleThe issue is stale. It will be closed within 7 days unless there are further conversation labelOct 15, 2023
@larrylian
Copy link
ContributorAuthor

@jjyao Can you help to review this pr ?

Copy link
Collaborator

@jjyaojjyao left a comment

Choose a reason for hiding this comment

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

LG and very sorry for the late view!

len(key) >= ray_constants.RAY_LABEL_MAX_LENGTH
or len(key) == 0
or len(value) >= ray_constants.RAY_LABEL_MAX_LENGTH
or len(value) == 0
Copy link
Collaborator

Choose a reason for hiding this comment

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

I can understand key cannot be empty but I guess value can be empty? There are cases where you only care if a key exists or not. (k8s label value can be empty).

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

It's ok, The value can be empty. I'll fix.

jjyao reacted with thumbs up emoji
… to the node labelsSigned-off-by: LarryLian <554538252@qq.com>
f"This is reserved for Ray defined labels."
)
if len(key) >= ray._raylet.RAY_LABEL_MAX_LENGTH or len(key) == 0:
raise ValueError(
"The keys length of custom lables "
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
"Thekeys lengthofcustom lables "
"Thekeyofnode labels "

raise ValueError(
"The keys length of custom lables "
"cannot be empty or exceed "
f"{ray._raylet.RAY_LABEL_MAX_LENGTH - 1} characters, "
Copy link
Collaborator

Choose a reason for hiding this comment

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

It's a bit confusing. RAY_LABEL_MAX_LENGTH means it can be exactly that number of characters but not more.

f"{ray._raylet.RAY_LABEL_MAX_LENGTH - 1} characters, "
f"invalid label key: {key}."
)
if len(value) >= ray._raylet.RAY_LABEL_MAX_LENGTH:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same here, instead of >=, it should be >

)
if len(value) >= ray._raylet.RAY_LABEL_MAX_LENGTH:
raise ValueError(
"The values length of custom lables "
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
"Thevalues lengthofcustom lables "
"Thevalueofnode labels "

if len(value) >= ray._raylet.RAY_LABEL_MAX_LENGTH:
raise ValueError(
"The values length of custom lables "
"cannot be exceed "
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
"cannotbeexceed "
"cannot exceed "

"The values length of custom lables "
"cannot be exceed "
f"{ray._raylet.RAY_LABEL_MAX_LENGTH - 1} characters, "
f"invalid label: {key}:{value}."
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
f"invalid label:{key}:{value}."
f"invalid label value:{value} for key{key}."

Comment on lines +1976 to +1978
"The keys and values of custom lables must "
"consist of letters from `a-z0-9A-Z` or `-` or `_` or `.` or `/`, "
f"invalid label: {key}:{value}."
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
"The keys and values ofcustom lables must "
"consist of letters from`a-z0-9A-Z` or `-` or `_` or `.` or `/`,"
f"invalid label:{key}:{value}."
"The keys and values ofnode labels can "
"only contain`a-zA-Z0-9\-_./`"
f"invalid label:{key}:{value}."

def is_valid_label_string(s):
if len(s) == 0:
return True
pattern = r"^[a-zA-Z0-9\-_./]+$"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Actually after some thoughts. I feel having a limitation on the length makes sense. But for valid characters, it seems a bit arbitrary. Why don't we allow: or+? We are also not following k8s since k8s doesn't allow\. Also I don't think we should strictly follow k8s.

Should we just have length limitations?

@anyscalesamanyscalesam added triageNeeds triage (eg: priority, bug/not-bug, and owning component) staleThe issue is stale. It will be closed within 7 days unless there are further conversation coreIssues that should be addressed in Ray Core labelsMay 15, 2024
@stalestalebot removed the staleThe issue is stale. It will be closed within 7 days unless there are further conversation labelMay 15, 2024
@jjyaojjyao added P1Issue that should be fixed within a few weeks @external-author-action-requiredAlternate tag for PRs where the author doesn't have labeling permission. and removed triageNeeds triage (eg: priority, bug/not-bug, and owning component) labelsSep 16, 2024
@jjyaojjyao assignedMengjinYan and unassignedjjyaoMar 19, 2025
@hainesmichaelchainesmichaelc added the community-contributionContributed by the community labelApr 4, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@jjyaojjyaojjyao left review comments

At least 1 approving review is required to merge this pull request.

Assignees

@MengjinYanMengjinYan

Labels
community-contributionContributed by the communitycoreIssues that should be addressed in Ray Core@external-author-action-requiredAlternate tag for PRs where the author doesn't have labeling permission.P1Issue that should be fixed within a few weeks
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

5 participants
@larrylian@jjyao@MengjinYan@hainesmichaelc@anyscalesam

[8]ページ先頭

©2009-2025 Movatter.jp