Skip to content
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

[autoscaler] Add env RAY_ENABLE_CLUSTER_STATUS_LOG to disable periodic cluster status log. #31869

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion python/ray/autoscaler/_private/autoscaler.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
AUTOSCALER_MAX_CONCURRENT_LAUNCHES,
AUTOSCALER_MAX_LAUNCH_BATCH,
AUTOSCALER_MAX_NUM_FAILURES,
AUTOSCALER_STATUS_LOG,
AUTOSCALER_UPDATE_INTERVAL_S,
DISABLE_LAUNCH_CONFIG_CHECK_KEY,
DISABLE_NODE_UPDATERS_KEY,
Expand Down Expand Up @@ -414,7 +415,8 @@ def _update(self):
)

# Update status strings
logger.info(self.info_string())
if AUTOSCALER_STATUS_LOG:
logger.info(self.info_string())
legacy_log_info_string(self, self.non_terminated_nodes.worker_ids)

if not self.provider.is_readonly():
Expand Down
3 changes: 3 additions & 0 deletions python/ray/autoscaler/_private/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ def env_integer(key, default):
return default


# Whether autoscaler cluster status logging is enabled. Set to 0 disable.
AUTOSCALER_STATUS_LOG = env_integer("RAY_ENABLE_CLUSTER_STATUS_LOG", 1)

# The name of the environment variable for plugging in a utilization scorer.
AUTOSCALER_UTILIZATION_SCORER_KEY = "RAY_AUTOSCALER_UTILIZATION_SCORER"

Expand Down
37 changes: 37 additions & 0 deletions python/ray/tests/test_autoscaler.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import copy
import logging
import sys
import json
import os
Expand Down Expand Up @@ -3801,6 +3802,41 @@ def testInitializeSDKArguments(self):
with self.assertRaises(TypeError):
request_resources(bundles=[{"foo": 1}, {"bar": "baz"}])

def test_autoscaler_status_log(self):
self._test_autoscaler_status_log(status_log_enabled_env=1)
self._test_autoscaler_status_log(status_log_enabled_env=0)

def _test_autoscaler_status_log(self, status_log_enabled_env: int):
mock_logger = Mock(spec=logging.Logger(""))
with patch.multiple(
"ray.autoscaler._private.autoscaler",
logger=mock_logger,
AUTOSCALER_STATUS_LOG=status_log_enabled_env,
):
config = copy.deepcopy(SMALL_CLUSTER)
config_path = self.write_config(config)
runner = MockProcessRunner()
mock_metrics = Mock(spec=AutoscalerPrometheusMetrics())
self.provider = MockProvider()
autoscaler = MockAutoscaler(
config_path,
LoadMetrics(),
MockNodeInfoStub(),
max_failures=0,
process_runner=runner,
update_interval_s=0,
prom_metrics=mock_metrics,
)
autoscaler.update()
status_log_found = False
for call in mock_logger.info.call_args_list:
args, _ = call
arg = args[0]
if " Autoscaler status: " in arg:
status_log_found = True
break
assert status_log_found is bool(status_log_enabled_env)


def test_import():
"""This test ensures that all the autoscaler imports work as expected to
Expand All @@ -3823,6 +3859,7 @@ def test_prom_null_metric_inc_fix():
NullMetric().inc(5)



if __name__ == "__main__":

if os.environ.get("PARALLEL_CI"):
Expand Down