lablup / lablup/backend.ai

[Domain] Move endpoints.domain FK to endpoints.domain_id

Open
#11,720 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
670
Forks
183
Avg merge
15h 13m
Merged PRs (30d)
368

Description

Goal

Move the foreign key reference from ``endpoints.domain`` (string, → ``domains.name``) to a new ``endpoints.domain_id`` (UUID, → ``domains.id``). The legacy ``domain`` string column is retained without a FK constraint; removal is deferred to BA-6122. ``domains`` keeps ``name`` as PK in this story — the PK swap is BA-6046.

Scope

1. Alembic: single revision, parent ``down_revision = fdc9d6ac49b4``. Add ``endpoints.domain_id`` UUID column (NOT NULL). Backfill via join on ``domains.name``. Drop legacy ``domain → domains.name`` FK (which used ``ON DELETE RESTRICT``); create new ``domain_id → domains.id`` FK with the same ``RESTRICT`` semantics. Downgrade reverses.

2. ORM: add ``domain_id: Mapped[DomainID]`` on ``EndpointRow``; keep ``domain`` column (drop only its FK clause).

3. Create / update specs: add ``domain_id: DomainID`` to both ``EndpointCreatorSpec`` (in ``repositories/model_serving/creators.py``) and ``DeploymentMetadataFields`` (in ``repositories/deployment/creators/deployment.py``). Propagate ``domain_id`` from the upstream ``DeploymentMetadata`` data type, which also gains a ``domain_id`` field.

4. API entry points: convert ``domain_name`` → ``domain_id`` via ``ResolveDomainIDByNameAction`` in:

- ``api/rest/deployment/handler.py`` + ``api/rest/deployment/adapter.py::CreateDeploymentAdapter.build_creator``

- ``api/rest/service/handler.py``

- ``api/adapters/deployment/adapter.py``

- ``api/adapters/model_card/adapter.py`` (vfolder-based deployment creation)

- ``api/adapters/vfolder/adapter.py`` (vfolder-based deployment creation)

5. Internal sokovan callers that construct ``EndpointRow`` / ``DeploymentMetadata``: ``sokovan/deployment/deployment_controller.py``, ``models/endpoint/row.py::_build_deployment_info`` (already reads ``self.domain_id`` after the ORM change).

6. Update ``EndpointData`` in ``manager/data/model_serving/types.py`` to expose ``domain_id`` for downstream service callers (used to populate ``EndpointTokenCreatorSpec.domain_id`` in the endpoint_tokens story BA-6128).

7. Tests: update fixtures that construct ``EndpointRow`` directly so ``domain_id`` is populated.

Parallelism

Independent of the other 9 referencing-table stories. Coordinates with BA-6128 (endpoint_tokens) only via ``EndpointData.domain_id`` exposure — additive and safe to merge in either order.

Out of scope

- ``domains`` PK swap — BA-6046.

- Legacy column drop — BA-6122.

JIRA Issue: BA-6127

Contributor guide

Open the contributing guide

Research direction

Start with the Alembic revision, EndpointRow, and the creator specs named in the issue, then trace the listed API adapters and handlers that construct deployment metadata. Update the direct EndpointRow fixtures and run the affected migration, ORM, deployment, and endpoint tests. Done means upgrade and downgrade work, callers provide domain_id, and the listed tests pass.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend-api-design, databases
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.