Skip to content

Commit 633e240

Browse files
manhld0206peterxcli
authored andcommitted
fix: fix multiple deployment same name resolve (ray-project#59577)
## Description Fix ingress deployment name could be modified if child deployment has the same name ## Related issues Fixes ray-project#53295 ## Additional information Because there is a child app with the same name as the ingress deployment app, the ingress deployment app name was modified during _build_app_recursive function. Therefore we should use the modified name instead. Another solution is changing the child_app name instead of the ingress deployment app name --------- Signed-off-by: Le Duc Manh <naruto12308@gmail.com> Signed-off-by: peterxcli <peterxcli@gmail.com>
1 parent 3e0f937 commit 633e240

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

python/ray/serve/_private/build_app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def build_app(
108108
name=name,
109109
route_prefix=route_prefix,
110110
logging_config=logging_config,
111-
ingress_deployment_name=app._bound_deployment.name,
111+
ingress_deployment_name=deployment_names[app],
112112
deployments=deployments,
113113
deployment_handles={
114114
deployment_names[app]: handle for app, handle in handles.items()

python/ray/serve/tests/unit/test_build_app.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -521,5 +521,29 @@ class D:
521521
assert built_app_default.name == "app-default"
522522

523523

524+
def test_ingress_name_got_modified():
525+
"""Test that the ingress deployment name is modified when there are name
526+
collisions.
527+
"""
528+
529+
@serve.deployment
530+
class D:
531+
pass
532+
533+
app = D.bind(D.bind(D.bind()))
534+
built_app: BuiltApplication = build_app(
535+
app,
536+
name="default",
537+
make_deployment_handle=FakeDeploymentHandle.from_deployment,
538+
)
539+
540+
# The ingress deployment name should be modified to avoid collision.
541+
assert built_app.ingress_deployment_name == "D_2"
542+
543+
# The ingress deployment should be the last one.
544+
assert len(built_app.deployments) == 3
545+
assert built_app.deployments[-1].name == "D_2"
546+
547+
524548
if __name__ == "__main__":
525549
sys.exit(pytest.main(["-v", "-s", __file__]))

0 commit comments

Comments
 (0)