-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
[core] Add the function to cleanup Redis backend. #31782
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -577,3 +577,40 @@ def use_gcs_for_bootstrap(): | |
This function is included for the purposes of backwards compatibility. | ||
""" | ||
return True | ||
|
||
|
||
def cleanup_redis_storage( | ||
host: str, port: int, password: str, use_ssl: bool, storage_namespace: str | ||
): | ||
"""This function is used to cleanup the storage. Before we having | ||
a good design for storage backend, it can be used to delete the old | ||
data. It support redis cluster and non cluster mode. | ||
|
||
Args: | ||
host: The host address of the Redis. | ||
port: The port of the Redis. | ||
password: The password of the Redis. | ||
use_ssl: Whether to encrypt the connection. | ||
storage_namespace: The namespace of the storage to be deleted. | ||
""" | ||
|
||
from ray._raylet import del_key_from_storage # type: ignore | ||
|
||
if not isinstance(host, str): | ||
raise ValueError("Host must be a string") | ||
|
||
if not isinstance(password, str): | ||
raise ValueError("Password must be a string") | ||
|
||
if port < 0: | ||
raise ValueError(f"Invalid port: {port}") | ||
|
||
if not isinstance(use_ssl, bool): | ||
raise TypeError("use_ssl must be a boolean") | ||
|
||
if not isinstance(storage_namespace, str): | ||
raise ValueError("storage namespace must be a string") | ||
|
||
# Right now, GCS store all data into a hash set key by storage_namespace. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. comment added here. |
||
# So we only need to delete the specific key to cleanup the cluster. | ||
return del_key_from_storage(host, port, password, use_ssl, storage_namespace) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
can we make these all default to the same environment variables that the GCS does?
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.
so called
ray start
and this utility with the same env variables "just works"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 don't think it's doable unless we baked everything into OS envs. I'd say maybe app layer can have a wrapper on top of this (host/port can be retrieved from RAY_REDIS_ADDRESS and storage_namespace can be retrieved from RAY_external_storage_namespace). These should be given by the user.
For password it seems not good (you might not need to use this if it's a closed network).
I'm trying to make the utils not deep coupled with the existing ray api since the current API might be updated in the future (we'll make it backward compatible) and as you can see the current API is really bad, for example, redis address and redis password are passed to ray in different style.
Let me know if it's hard to do it in app layer and we'll see what we can do.
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 the current API is definitely pretty bad lol.
Ok, I think it's fine to not pull them from the env vars.