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

fix: detect container port allocation collision when starting session #1750

Merged
merged 4 commits into from
Mar 29, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions changes/1750.fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Abort container creation when duplicate container port definition exists
19 changes: 19 additions & 0 deletions src/ai/backend/agent/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -1853,6 +1853,16 @@ async def create_kernel(
environ["BACKEND_MODEL_NAME"] = model["name"]
environ["BACKEND_MODEL_PATH"] = model["model_path"]
if service := model.get("service"):
overlapping_services = [
s
for s in service_ports
if s["container_ports"][0] == service["port"]
]
if len(overlapping_services) > 0:
raise AgentError(
f"Port {service['port']} overlaps with built-in service"
f" {overlapping_services[0]['name']}"
)
service_ports.append({
"name": f"{model['name']}-{service['port']}",
"protocol": ServicePortProtocols.PREOPEN,
Expand All @@ -1875,6 +1885,15 @@ async def create_kernel(
):
port_map[sport["name"]] = sport
for port_no in preopen_ports:
overlapping_services = [
s for s in service_ports if s["container_ports"][0] == port_no
]
if len(overlapping_services) > 0:
raise AgentError(
f"Port {port_no} overlaps with built-in service"
f" {overlapping_services[0]['name']}"
)

preopen_sport: ServicePort = {
"name": str(port_no),
"protocol": ServicePortProtocols.PREOPEN,
Expand Down
Loading