-
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
Revert "Revert "[autoscaler][observability] Autoscaler emit cluster/pending logical resource metrics"" #30552
Merged
wuisawesome
merged 20 commits into
ray-project:master
from
wuisawesome:autoscaler_resource_metrics
Nov 22, 2022
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
297d1f0
.
88da294
.
5bfdd8a
seems to work
45f9e57
.
771146a
.
aadcbd6
.
0a44631
Merge branch 'master' of github.com:ray-project/ray into autoscaler_r…
ad63816
.
83342f3
.
7c2df4f
.
510bda8
.
2218158
.
b7362af
.
9e05a84
Merge branch 'master' of github.com:ray-project/ray into autoscaler_r…
83e6bb3
.
97c1125
Merge branch 'master' of github.com:ray-project/ray into autoscaler_r…
9d085b1
Merge branch 'master' of github.com:ray-project/ray into autoscaler_r…
32f251a
.
1a33c3f
Merge branch 'master' of github.com:ray-project/ray into autoscaler_r…
22f005f
Revert "Revert "[autoscaler][observability] Autoscaler emit cluster/p…
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
import subprocess | ||
from ray.autoscaler._private.constants import AUTOSCALER_METRIC_PORT | ||
|
||
import ray | ||
from ray._private.test_utils import ( | ||
wait_for_condition, | ||
get_metric_check_condition, | ||
) | ||
from ray.cluster_utils import AutoscalingCluster | ||
|
||
|
||
def test_ray_status_e2e(shutdown_only): | ||
cluster = AutoscalingCluster( | ||
head_resources={"CPU": 0}, | ||
worker_node_types={ | ||
"type-i": { | ||
"resources": {"CPU": 1, "fun": 1}, | ||
"node_config": {}, | ||
"min_workers": 1, | ||
"max_workers": 1, | ||
}, | ||
"type-ii": { | ||
"resources": {"CPU": 1, "fun": 100}, | ||
"node_config": {}, | ||
"min_workers": 1, | ||
"max_workers": 1, | ||
}, | ||
}, | ||
) | ||
|
||
try: | ||
cluster.start() | ||
ray.init(address="auto") | ||
|
||
@ray.remote(num_cpus=0, resources={"fun": 2}) | ||
class Actor: | ||
def ping(self): | ||
return None | ||
|
||
actor = Actor.remote() | ||
ray.get(actor.ping.remote()) | ||
|
||
assert "Demands" in subprocess.check_output("ray status", shell=True).decode() | ||
assert ( | ||
"Total Demands" | ||
not in subprocess.check_output("ray status", shell=True).decode() | ||
) | ||
assert ( | ||
"Total Demands" | ||
in subprocess.check_output("ray status -v", shell=True).decode() | ||
) | ||
assert ( | ||
"Total Demands" | ||
in subprocess.check_output("ray status --verbose", shell=True).decode() | ||
) | ||
finally: | ||
cluster.shutdown() | ||
|
||
|
||
def test_metrics(shutdown_only): | ||
cluster = AutoscalingCluster( | ||
head_resources={"CPU": 0}, | ||
worker_node_types={ | ||
"type-i": { | ||
"resources": {"CPU": 1}, | ||
"node_config": {}, | ||
"min_workers": 1, | ||
"max_workers": 1, | ||
}, | ||
"type-ii": { | ||
"resources": {"CPU": 1}, | ||
"node_config": {}, | ||
"min_workers": 1, | ||
"max_workers": 1, | ||
}, | ||
}, | ||
) | ||
|
||
try: | ||
cluster.start() | ||
info = ray.init(address="auto") | ||
autoscaler_export_addr = "{}:{}".format( | ||
info.address_info["node_ip_address"], AUTOSCALER_METRIC_PORT | ||
) | ||
|
||
@ray.remote(num_cpus=1) | ||
class Foo: | ||
def ping(self): | ||
return True | ||
|
||
zero_reported_condition = get_metric_check_condition( | ||
{"autoscaler_cluster_resources": 0, "autoscaler_pending_resources": 0}, | ||
export_addr=autoscaler_export_addr, | ||
) | ||
wait_for_condition(zero_reported_condition) | ||
|
||
actors = [Foo.remote() for _ in range(2)] | ||
ray.get([actor.ping.remote() for actor in actors]) | ||
|
||
two_cpu_no_pending_condition = get_metric_check_condition( | ||
{"autoscaler_cluster_resources": 2, "autoscaler_pending_resources": 0}, | ||
export_addr=autoscaler_export_addr, | ||
) | ||
wait_for_condition(two_cpu_no_pending_condition) | ||
# TODO (Alex): Ideally we'd also assert that pending_resources | ||
# eventually became 1 or 2, but it's difficult to do that in a | ||
# non-racey way. (Perhaps we would need to artificially delay the fake | ||
# autoscaler node launch?). | ||
|
||
finally: | ||
cluster.shutdown() | ||
|
||
|
||
if __name__ == "__main__": | ||
import sys | ||
import os | ||
import pytest | ||
|
||
if os.environ.get("PARALLEL_CI"): | ||
sys.exit(pytest.main(["-n", "auto", "--boxed", "-vs", __file__])) | ||
else: | ||
sys.exit(pytest.main(["-sv", __file__])) |
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
Oops, something went wrong.
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.
This is the only difference