Skip to content

Commit 6e954b6

Browse files
iamjustinhsuFuture-Outlier
authored andcommitted
[core][dashboard] clearer error msg for exceeding list actors limit (ray-project#58255)
## Description Currently, the `ray.util.state.list_actors(limit=N)` API will return a details for at most N actors. However, when N exceeds the default value for `RAY_MAX_LIMIT_FROM_API_SERVER=10_000`, the error will fail with a misleading message (the error msg being that the dashboard or API server is unavailable, even if it is available). The reason why this fails is because we don't handle `ValueErrors`, and default throw a 500 error. My solution is to handle that, and open to suggestions/alternatives NOTE: I noticed it still fails with internal_server error, I think this should be a 4XX error, but it looks like that will require more code changes since it uses a very ubiquitous function: `do_reply`. Gemini suggests returning `rest_response` directly, happy to follow those orders too ### Before ```python >>> import ray >>> import ray.util.state >>> ray.init() >>> ray.util.state.list_actors(limit=100000) ray.util.state.exception.RayStateApiException: Failed to make request to http://127.0.0.1:8265/api/v0/actors. Failed to connect to API server. Please check the API server log for details. Make sure dependencies are installed with `pip install ray[default]`. Please also check dashboard is available, and included when starting ray cluster, i.e. `ray start --include-dashboard=True --head`. Response(url=http://127.0.0.1:8265/api/v0/actors?limit=100000&timeout=24&detail=False&exclude_driver=True&server_timeout_multiplier=0.8,status=500) ``` ### After ```python >>> import ray >>> import ray.util.state >>> ray.init() >>> ray.util.state.list_actors(limit=100000) ray.util.state.exception.RayStateApiException: API server internal error. See dashboard.log file for more details. Error: Given limit 100000 exceeds the supported limit 10000. Use a lower limit, or set the RAY_MAX_LIMIT_FROM_API_SERVER=limit ``` ## Related issues None ## Additional information None --------- Signed-off-by: iamjustinhsu <[email protected]> Signed-off-by: Future-Outlier <[email protected]>
1 parent f0781b7 commit 6e954b6

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

python/ray/dashboard/state_api_utils.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ async def handle_list_api(
4444
error_message="",
4545
result=asdict(result),
4646
)
47+
except ValueError as e:
48+
return do_reply(success=False, error_message=str(e), result=None)
4749
except DataSourceUnavailable as e:
4850
return do_reply(success=False, error_message=str(e), result=None)
4951

@@ -70,7 +72,9 @@ def options_from_req(req: aiohttp.web.Request) -> ListApiOptions:
7072
if limit > RAY_MAX_LIMIT_FROM_API_SERVER:
7173
raise ValueError(
7274
f"Given limit {limit} exceeds the supported "
73-
f"limit {RAY_MAX_LIMIT_FROM_API_SERVER}. Use a lower limit."
75+
f"Given limit {limit} exceeds the supported "
76+
f"limit {RAY_MAX_LIMIT_FROM_API_SERVER}. Use a lower limit, or set the "
77+
f"`RAY_MAX_LIMIT_FROM_API_SERVER` environment variable to a larger value."
7478
)
7579

7680
timeout = int(req.query.get("timeout", 30))

0 commit comments

Comments
 (0)