-
Notifications
You must be signed in to change notification settings - Fork 7.4k
[Core][Autoscaler] Configure idleTimeoutSeconds per node type #48813
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
Merged
rickyyx
merged 10 commits into
ray-project:master
from
ryanaoleary:autoscaler-node-type-idletimeout
Nov 24, 2024
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
21e0b27
Add idleTimeoutSeconds initial commit
ryanaoleary d014a17
Update python/ray/autoscaler/_private/kuberay/autoscaling_config.py
ryanaoleary a97ca9d
Update python/ray/autoscaler/v2/instance_manager/config.py
ryanaoleary 21b12c0
Index by node_type
ryanaoleary a3e7210
Add test where node type's idle_timeout_s overrides autoscaler
ryanaoleary 4082e8c
Merge branch 'master' into autoscaler-node-type-idletimeout
ryanaoleary 5276ff7
Edit test
ryanaoleary c9ad7fe
lint
ryanaoleary 1bd8afb
Use float in schema
ryanaoleary fd1bbc3
Merge branch 'master' into autoscaler-node-type-idletimeout
rickyyx 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -1434,6 +1434,82 @@ def test_idle_termination_with_min_worker(min_workers): | |
| assert len(to_terminate) == 0 | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("node_type_idle_timeout_s", [1, 2, 10]) | ||
| def test_idle_termination_with_node_type_idle_timeout(node_type_idle_timeout_s): | ||
|
Member
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. Nice! |
||
| """ | ||
| Test that idle nodes are terminated when idle_timeout_s is set for node type. | ||
| """ | ||
| scheduler = ResourceDemandScheduler(event_logger) | ||
|
|
||
| node_type_configs = { | ||
| "type_cpu_with_idle_timeout": NodeTypeConfig( | ||
| name="type_cpu", | ||
| resources={"CPU": 1}, | ||
| min_worker_nodes=0, | ||
| max_worker_nodes=5, | ||
| idle_timeout_s=node_type_idle_timeout_s, | ||
| launch_config_hash="hash1", | ||
| ), | ||
| } | ||
|
|
||
| idle_time_s = 5 | ||
| constraints = [] | ||
|
|
||
| request = sched_request( | ||
| node_type_configs=node_type_configs, | ||
| instances=[ | ||
| make_autoscaler_instance( | ||
| im_instance=Instance( | ||
| instance_type="type_cpu_with_idle_timeout", | ||
| status=Instance.RAY_RUNNING, | ||
| launch_config_hash="hash1", | ||
| instance_id="i-1", | ||
| node_id="r-1", | ||
| ), | ||
| ray_node=NodeState( | ||
| node_id=b"r-1", | ||
| ray_node_type_name="type_cpu_with_idle_timeout", | ||
| available_resources={"CPU": 0}, | ||
| total_resources={"CPU": 1}, | ||
| idle_duration_ms=0, # Non idle | ||
| status=NodeStatus.RUNNING, | ||
| ), | ||
| cloud_instance_id="c-1", | ||
| ), | ||
| make_autoscaler_instance( | ||
| im_instance=Instance( | ||
| instance_id="i-2", | ||
| instance_type="type_cpu_with_idle_timeout", | ||
| status=Instance.RAY_RUNNING, | ||
| launch_config_hash="hash1", | ||
| node_id="r-2", | ||
| ), | ||
| ray_node=NodeState( | ||
| ray_node_type_name="type_cpu_with_idle_timeout", | ||
| node_id=b"r-2", | ||
| available_resources={"CPU": 1}, | ||
| total_resources={"CPU": 1}, | ||
| idle_duration_ms=idle_time_s * 1000, | ||
| status=NodeStatus.IDLE, | ||
| ), | ||
| cloud_instance_id="c-2", | ||
| ), | ||
| ], | ||
| # Set autoscaler idle_timeout_s to a value greater than | ||
| # node_type_idle_timeout_s and idle_time_s. | ||
| idle_timeout_s=idle_time_s * 1000, | ||
| cluster_resource_constraints=constraints, | ||
| ) | ||
|
|
||
| reply = scheduler.schedule(request) | ||
| _, to_terminate = _launch_and_terminate(reply) | ||
| if node_type_idle_timeout_s <= idle_time_s: | ||
| assert len(to_terminate) == 1 | ||
| assert to_terminate == [("i-2", "r-2", TerminationRequest.Cause.IDLE)] | ||
| else: | ||
| assert len(to_terminate) == 0 | ||
|
|
||
|
|
||
| def test_gang_scheduling(): | ||
| """ | ||
| Test that gang scheduling works. | ||
|
|
||
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.
nit: should we enforce it as integer with a cast when we add this? I see it being int as part of the schema
Or we could make this a float in the schema too. No preference over this.
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'll change it to a
numbertype in the schema and then add a cast to float when we callidle_timeout_s = group_spec.get(IDLE_SECONDS_KEY), since I implemented it as an int in the RayCluster CRD for consistency with the other field: https://github.com/ray-project/kuberay/blob/925effe34022c72c41691c0b79d8d3051d4a1b77/ray-operator/apis/ray/v1/raycluster_types.go#L94There 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 ran the tests again and implemented this change in: 1bd8afb
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.
Awesome, thanks for the great work!