forked from ray-project/ray
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Revert "[autoscaler][observability] Autoscaler emit cluster/p…
…ending logical resource metrics"" (ray-project#30552) See ray-project#29820 for most of the details of the PR. The only difference is improving the NullMetric stub to not fail when tagging labesl for metrics. This reverts commit f9092dc. Co-authored-by: Alex <[email protected]> Signed-off-by: Weichen Xu <[email protected]>
- Loading branch information
1 parent
c1b4c81
commit d50b901
Showing
9 changed files
with
239 additions
and
76 deletions.
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.