Skip to content

Make DefaultClusterAutoscalerV2 knobs configurable via environment variables - #60111

Closed
aliceco01 wants to merge 1 commit into
ray-project:masterfrom
aliceco01:data-autoscaler-env-vars
Closed

aliceco01 wants to merge 1 commit into
ray-project:masterfrom
aliceco01:data-autoscaler-env-vars

Conversation

@aliceco01

Copy link
Copy Markdown
Contributor

Summary

  • Import env_float/env_integer and make DefaultClusterAutoscalerV2 knobs env-configurable:
    • RAY_DATA_CLUSTER_SCALING_UP_UTIL_THRESHOLD
    • RAY_DATA_CLUSTER_UTIL_CHECK_INTERVAL_S
    • RAY_DATA_CLUSTER_UTIL_AVG_WINDOW_S
    • RAY_DATA_CLUSTER_SCALING_UP_DELTA
    • RAY_DATA_MIN_GAP_BETWEEN_AUTOSCALING_REQUESTS
    • RAY_DATA_AUTOSCALING_REQUEST_EXPIRE_TIME_S
  • Keep constructor backward compatible; allow DI for autoscaling coordinator and node-count provider.

Testing

  • Not run (env overrides only; defaults unchanged without env vars).

@aliceco01
aliceco01 requested a review from a team as a code owner January 13, 2026 20:04

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces configurability for several knobs in DefaultClusterAutoscalerV2 via environment variables, which is a great improvement for flexibility. It also refactors the class to allow dependency injection for the autoscaling coordinator and node count provider, improving testability. The changes are well-structured. I've found one bug in a log message that could be misleading, and I've also suggested a minor refactoring for more idiomatic code.

@@ -206,7 +249,7 @@ def on_executor_shutdown(self):
msg = (
f"Failed to cancel resource request for {self._requester_id}."
" The request will still expire after the timeout of"
f" {self.MIN_GAP_BETWEEN_AUTOSCALING_REQUESTS} seconds."
f" {self._min_gap_between_autoscaling_requests_s} seconds."

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The log message here incorrectly uses _min_gap_between_autoscaling_requests_s as the expiration timeout. The actual expiration timeout is defined by AUTOSCALING_REQUEST_EXPIRE_TIME_S. This was also an issue in the previous version of the code. Using the wrong variable can be misleading when debugging. Please use self.AUTOSCALING_REQUEST_EXPIRE_TIME_S instead.

                f" {self.AUTOSCALING_REQUEST_EXPIRE_TIME_S} seconds."

Comment on lines +170 to +172
if autoscaling_coordinator is None:
autoscaling_coordinator = DefaultAutoscalingCoordinator()
self._autoscaling_coordinator = autoscaling_coordinator

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This block of code for initializing self._autoscaling_coordinator can be written more concisely. Using the or operator is more idiomatic in Python for handling default values when None is the alternative.

        self._autoscaling_coordinator = autoscaling_coordinator or DefaultAutoscalingCoordinator()

@bveeramani bveeramani left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there are some merge conflicts. Would you mind resolve thme?

@aliceco01
aliceco01 force-pushed the data-autoscaler-env-vars branch 2 times, most recently from 3881492 to 8f1f762 Compare January 13, 2026 20:24

@bveeramani bveeramani left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost LGTM

Comment on lines -235 to +251
f" {self._min_gap_between_autoscaling_requests_s} seconds."
f" {self.AUTOSCALING_REQUEST_EXPIRE_TIME_S} seconds."

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert unrelated diff?

@aliceco01
aliceco01 force-pushed the data-autoscaler-env-vars branch from 8f1f762 to 8371e1c Compare January 13, 2026 21:20
@ray-gardener ray-gardener Bot added data Ray Data-related issues community-contribution Contributed by the community labels Jan 14, 2026
@aliceco01 aliceco01 closed this Jan 19, 2026
bveeramani added a commit that referenced this pull request Aug 20, 2026
…5317)

The warning logged when cancelling a resource request fails during
executor
shutdown reports `_min_gap_between_autoscaling_requests_s` (default 10s)
as
the expiry timeout, but the request is actually submitted with
`expire_after_s=AUTOSCALING_REQUEST_EXPIRE_TIME_S` (default 180s) in
`_send_resource_request`. This corrects the log message to reference the
real expiry value, so operators debugging shutdown behavior aren't
misled
about how long a stale resource request will linger.

Log-message-only change; no behavior change.

Related to #60111 (originally identified there)

Verified the referenced constant matches the `expire_after_s` value used
in
`_send_resource_request` on current master.

Signed-off-by: Alice C <[email protected]>
Co-authored-by: Balaji Veeramani <[email protected]>
nadongjun pushed a commit to nadongjun/ray that referenced this pull request Oct 6, 2026
…y-project#65317)

The warning logged when cancelling a resource request fails during
executor
shutdown reports `_min_gap_between_autoscaling_requests_s` (default 10s)
as
the expiry timeout, but the request is actually submitted with
`expire_after_s=AUTOSCALING_REQUEST_EXPIRE_TIME_S` (default 180s) in
`_send_resource_request`. This corrects the log message to reference the
real expiry value, so operators debugging shutdown behavior aren't
misled
about how long a stale resource request will linger.

Log-message-only change; no behavior change.

Related to ray-project#60111 (originally identified there)

Verified the referenced constant matches the `expire_after_s` value used
in
`_send_resource_request` on current master.

Signed-off-by: Alice C <[email protected]>
Co-authored-by: Balaji Veeramani <[email protected]>
@aliceco01
aliceco01 deleted the data-autoscaler-env-vars branch November 12, 2026 11:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-contribution Contributed by the community data Ray Data-related issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants