diff --git a/python/ray/autoscaler/kubernetes/node_provider.py b/python/ray/autoscaler/kubernetes/node_provider.py index 85de6035d..a374397a7 100644 --- a/python/ray/autoscaler/kubernetes/node_provider.py +++ b/python/ray/autoscaler/kubernetes/node_provider.py @@ -161,16 +161,11 @@ def _add_service_name_to_service_port(spec, svc_name): for k in dict_keys: spec[k] = _add_service_name_to_service_port(spec[k], svc_name) - # The magic string ${RAY_POD_NAME} is replaced with - # the true service name, which is equal to the worker pod name. - if k == "serviceName": - if spec[k] != "${RAY_POD_NAME}": - raise ValueError( - "The value of serviceName must be set to " - "${RAY_POD_NAME}. It is automatically replaced " - "when using the autoscaler.") - else: - spec["serviceName"] = svc_name + if k == "serviceName" and spec[k] != svc_name: + raise ValueError( + "The value of serviceName must be set to " + "${RAY_POD_NAME}. It is automatically replaced " + "when using the autoscaler.") elif isinstance(spec, list): spec = [ @@ -178,6 +173,8 @@ def _add_service_name_to_service_port(spec, svc_name): ] elif isinstance(spec, str): + # The magic string ${RAY_POD_NAME} is replaced with + # the true service name, which is equal to the worker pod name. if "${RAY_POD_NAME}" in spec: spec = spec.replace("${RAY_POD_NAME}", svc_name) return spec