Skip to content

fix(BA-1610): Use correct attribute routings instead of routes for endpoints #4756

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

Merged
merged 3 commits into from
Jun 20, 2025

Conversation

rapsealk
Copy link
Member

Follow-up of #4109 and resolves #4755 (BA-1610)

This pull request fixes an issue with the incorrect usage of an attribute name in the codebase. The attribute routes has been replaced with the correct attribute routings to ensure proper functionality.

Fixes to attribute usage:

class EndpointRow(Base):
__tablename__ = "endpoints"
__table_args__ = (
CheckConstraint(
sa.or_(
sa.column("lifecycle_stage") == EndpointLifecycle.DESTROYED.value,
sa.column("image").isnot(None),
),
name="ck_image_required_unless_destroyed",
),
)
id = EndpointIDColumn()
name = sa.Column("name", sa.String(length=512), nullable=False)
created_user = sa.Column("created_user", GUID, nullable=False)
session_owner = sa.Column("session_owner", GUID, nullable=False)
# minus session count means this endpoint is requested for removal
replicas = sa.Column("replicas", sa.Integer, nullable=False, default=0, server_default="0")
image = sa.Column("image", GUID)
model = sa.Column(
"model",
GUID,
sa.ForeignKey("vfolders.id", ondelete="SET NULL"),
nullable=True,
)
model_mount_destination = sa.Column(
"model_mount_destination",
sa.String(length=1024),
nullable=False,
default="/models",
server_default="/models",
)
domain = sa.Column(
"domain",
sa.String(length=64),
sa.ForeignKey("domains.name", ondelete="RESTRICT"),
nullable=False,
)
project = sa.Column(
"project",
GUID,
sa.ForeignKey("groups.id", ondelete="RESTRICT"),
nullable=False,
)
resource_group = sa.Column(
"resource_group",
sa.ForeignKey("scaling_groups.name", ondelete="RESTRICT"),
index=True,
nullable=False,
)
lifecycle_stage = sa.Column(
"lifecycle_stage",
EnumValueType(EndpointLifecycle),
nullable=False,
default=EndpointLifecycle.CREATED,
)
tag = sa.Column("tag", sa.String(length=64), nullable=True)
startup_command = sa.Column("startup_command", sa.Text, nullable=True)
bootstrap_script = sa.Column("bootstrap_script", sa.String(length=16 * 1024), nullable=True)
callback_url = sa.Column("callback_url", URLColumn, nullable=True, default=sa.null())
environ = sa.Column("environ", pgsql.JSONB(), nullable=True, default={})
open_to_public = sa.Column("open_to_public", sa.Boolean, default=False)
runtime_variant = sa.Column(
"runtime_variant",
StrEnumType(RuntimeVariant),
nullable=False,
default=RuntimeVariant.CUSTOM,
)
model_definition_path = sa.Column("model_definition_path", sa.String(length=128), nullable=True)
resource_slots = sa.Column("resource_slots", ResourceSlotColumn(), nullable=False)
url = sa.Column("url", sa.String(length=1024))
resource_opts = sa.Column("resource_opts", pgsql.JSONB(), nullable=True, default={})
cluster_mode = sa.Column(
"cluster_mode",
sa.String(length=16),
nullable=False,
default=ClusterMode.SINGLE_NODE,
server_default=ClusterMode.SINGLE_NODE.name,
)
cluster_size = sa.Column(
"cluster_size", sa.Integer, nullable=False, default=1, server_default="1"
)
extra_mounts = sa.Column(
"extra_mounts",
StructuredJSONObjectListColumn(VFolderMount),
nullable=False,
default=[],
server_default="[]",
)
retries = sa.Column("retries", sa.Integer, nullable=False, default=0, server_default="0")
created_at = sa.Column(
"created_at",
sa.DateTime(timezone=True),
server_default=sa.text("now()"),
nullable=True,
)
destroyed_at = sa.Column(
"destroyed_at",
sa.DateTime(timezone=True),
nullable=True,
)
routings = relationship("RoutingRow", back_populates="endpoint_row")
tokens = relationship(
"EndpointTokenRow",
back_populates="endpoint_row",
primaryjoin="foreign(EndpointTokenRow.endpoint) == EndpointRow.id",
)
endpoint_auto_scaling_rules = relationship(
"EndpointAutoScalingRuleRow", back_populates="endpoint_row"
)
image_row = relationship(
"ImageRow",
primaryjoin=lambda: foreign(EndpointRow.image) == ImageRow.id,
foreign_keys=[image],
back_populates="endpoints",
)
model_row = relationship("VFolderRow", back_populates="endpoints")
created_user_row = relationship(
"UserRow",
back_populates="created_endpoints",
foreign_keys=[created_user],
primaryjoin=lambda: foreign(EndpointRow.created_user) == UserRow.uuid,
)
session_owner_row = relationship(
"UserRow",
back_populates="owned_endpoints",
foreign_keys=[session_owner],
primaryjoin=lambda: foreign(EndpointRow.session_owner) == UserRow.uuid,
)

Checklist: (if applicable)

  • Milestone metadata specifying the target backport version
  • Mention to the original issue

@rapsealk rapsealk added the type:bug Reports about that are not working label Jun 20, 2025
@github-actions github-actions bot added size:XS ~10 LoC comp:manager Related to Manager component labels Jun 20, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR corrects the use of the endpoint attribute by replacing all references from routes to routings to ensure the filtering logic uses the intended field.

  • Update code in update_route to use endpoint.routings instead of endpoint.routes
  • Amend the changelog in changes/.fix.md to document the correct attribute

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/ai/backend/manager/services/model_serving/services/model_serving.py Replace endpoint.routes with endpoint.routings for healthy-route filtering
changes/.fix.md Document the switch from routes to routings

.fix.md -> 4756.fix.md

Co-authored-by: octodog <[email protected]>
Copy link
Member

@fregataa fregataa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@HyeockJinKim HyeockJinKim added this pull request to the merge queue Jun 20, 2025
@HyeockJinKim
Copy link
Collaborator

It seems like there's a problem with insufficient test codes..

Merged via the queue into main with commit 6fa36ce Jun 20, 2025
26 checks passed
@HyeockJinKim HyeockJinKim deleted the fix/BA-1610-endpoint-routes-attribute-error branch June 20, 2025 07:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:manager Related to Manager component size:XS ~10 LoC type:bug Reports about that are not working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AttributeError: EndpointRow object has no attribute 'routes'
4 participants