From b9fb902a4b59d995ff80c3fa1ed9bd92f5c08ac2 Mon Sep 17 00:00:00 2001 From: shrekris-anyscale <92341594+shrekris-anyscale@users.noreply.github.com> Date: Mon, 23 May 2022 09:31:23 -0700 Subject: [PATCH] Revert "[serve] Use soft constraint for placing controller on the head node (#24934)" (#25050) This reverts commit 737d16328c6a0855255acdac8f37e62d8abefd77. --- python/ray/serve/api.py | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/python/ray/serve/api.py b/python/ray/serve/api.py index fb5f0e008..6a4e873df 100644 --- a/python/ray/serve/api.py +++ b/python/ray/serve/api.py @@ -16,13 +16,6 @@ from starlette.requests import Request from uvicorn.config import Config from uvicorn.lifespan.on import LifespanOn -import ray -from ray import cloudpickle -from ray.experimental.dag import DAGNode -from ray.util.annotations import PublicAPI -from ray.util.scheduling_strategies import NodeAffinitySchedulingStrategy -from ray._private.usage import usage_lib - from ray.serve.common import DeploymentStatusInfo from ray.serve.config import ( AutoscalingConfig, @@ -40,17 +33,22 @@ from ray.serve.constants import ( from ray.serve.controller import ServeController from ray.serve.deployment import Deployment from ray.serve.exceptions import RayServeException +from ray.experimental.dag import DAGNode from ray.serve.handle import RayServeHandle from ray.serve.http_util import ASGIHTTPSender, make_fastapi_class_based_view from ray.serve.logging_utils import LoggingContext from ray.serve.utils import ( ensure_serialization_context, format_actor_name, + get_current_node_resource_key, get_random_letters, in_interactive_shell, DEFAULT, install_serve_encoders_to_fastapi, ) +from ray.util.annotations import PublicAPI +import ray +from ray import cloudpickle from ray.serve.deployment_graph import ClassNode, FunctionNode from ray.serve.application import Application from ray.serve.client import ServeControllerClient, get_controller_namespace @@ -62,6 +60,7 @@ from ray.serve.context import ( ) from ray.serve.pipeline.api import build as pipeline_build from ray.serve.pipeline.api import get_and_validate_ingress_deployment +from ray._private.usage import usage_lib logger = logging.getLogger(__file__) @@ -162,12 +161,8 @@ def start( lifetime="detached" if detached else None, max_restarts=-1, max_task_retries=-1, - # Schedule the controller on the head node with a soft constraint. This - # prefers it to run on the head node in most cases, but allows it to be - # restarted on other nodes in an HA cluster. - scheduling_strategy=NodeAffinitySchedulingStrategy( - ray.get_runtime_context().node_id, soft=True - ), + # Pin Serve controller on the head node. + resources={get_current_node_resource_key(): 0.01}, namespace=controller_namespace, max_concurrency=CONTROLLER_MAX_CONCURRENCY, ).remote(