Skip to content

fix(BA-5974): remove deployment name uniqueness constraint#11507

Merged
seedspirit merged 5 commits intomainfrom
fix/BA-5974-remove-deployment-name-uniqueness
May 8, 2026
Merged

fix(BA-5974): remove deployment name uniqueness constraint#11507
seedspirit merged 5 commits intomainfrom
fix/BA-5974-remove-deployment-name-uniqueness

Conversation

@fregataa
Copy link
Copy Markdown
Member

@fregataa fregataa commented May 7, 2026

Summary

  • Drop the partial unique index ix_endpoints_unique_name_when_active on (name, domain, project) and the application-level _check_endpoint_name_exists pre-check, so deployment names are no longer unique within a project.
  • The previous constraint scope (domain, project) did not match the my_deployments list scope (created_user), so a deployment created by another user in the same project blocked the create yet stayed invisible to the caller — leaving the user unable to choose the name and unable to locate the conflicting record.
  • Remove the now-unused DeploymentNameAlreadyExists exception and the duplicate-name test. Routing keys on route_id, and the inference session name template f"{endpoint.name}-{route_id}" already disambiguates downstream.

Test plan

  • Apply the new alembic migration on a database that holds the existing index and verify \d endpoints no longer lists ix_endpoints_unique_name_when_active.
  • Create two deployments with the same name in the same project (different and same created_user) and confirm both succeed.
  • Confirm my_deployments and project-scoped list queries return both rows as expected.
  • Downgrade the migration and verify the index is recreated with predicate lifecycle_stage NOT IN ('destroying', 'destroyed').

Resolves BA-5974

Copilot AI review requested due to automatic review settings May 7, 2026 10:41
@github-actions github-actions Bot added size:L 100~500 LoC comp:manager Related to Manager component comp:common Related to Common component require:db-migration Automatically set when alembic migrations are added or updated labels May 7, 2026
fregataa added a commit that referenced this pull request May 7, 2026
Copy link
Copy Markdown
Contributor

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

Note

Copilot was unable to run its full agentic suite in this review.

Removes the endpoint/deployment name uniqueness constraint so users can reuse deployment names within the same project without being blocked by deployments created by other users.

Changes:

  • Dropped the partial unique index on (name, domain, project) from the ORM model and added an Alembic migration to drop/recreate it.
  • Removed the application-level “duplicate name” pre-check and the DeploymentNameAlreadyExists exception.
  • Removed the unit test that asserted duplicate-name creation fails.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/unit/manager/repositories/deployment/test_deployment_repository.py Removes the duplicate-name rejection test.
src/ai/backend/manager/repositories/deployment/db_source/db_source.py Removes the app-level duplicate-name pre-check.
src/ai/backend/manager/models/endpoint/row.py Removes the partial unique index definition from the model.
src/ai/backend/manager/models/alembic/versions/c7d58e2a4f93_drop_endpoint_name_unique_index.py Adds migration to drop the index and recreate it on downgrade.
src/ai/backend/common/exception.py Removes DeploymentNameAlreadyExists exception type.
changes/11507.fix.md Adds changelog entry documenting behavior change.
Comments suppressed due to low confidence (1)

tests/unit/manager/repositories/deployment/test_deployment_repository.py:3663

  • This PR changes behavior to allow duplicate deployment names within the same project, but the test that enforced uniqueness was removed without adding a new test asserting the new behavior. Please add a unit test that creates two endpoints with the same name in the same (domain, project) and asserts both creations succeed (and optionally both are returned by relevant list queries if those are unit-tested here).
    async def test_create_endpoint_succeeds_with_different_name(
        self,
        deployment_repository: DeploymentRepository,
        test_domain: DomainRow,
        test_group: GroupRow,
        test_scaling_group: ScalingGroupRow,
        test_image_id: uuid.UUID,
    ) -> None:

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@fregataa fregataa requested a review from a team May 7, 2026 11:01
@jopemachine
Copy link
Copy Markdown
Member

Would it be better to remove the unique constraint entirely rather than applying it per scope?

fregataa and others added 5 commits May 8, 2026 10:52
The partial unique index on (name, domain, project) restricted deployment
name reuse to active rows, but `my_deployments` is scoped by `created_user`.
A deployment created by another user in the same project was invisible to
the caller yet still blocked the create, with no way to locate or clean up
the conflicting record.

Drop the partial unique index, the application-level pre-check, and the
now-unused `DeploymentNameAlreadyExists` exception. Routing keys on
`route_id` and the inference session name template
`f"{endpoint.name}-{route_id}"` already disambiguates downstream.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
After the upgrade allows duplicate (name, domain, project) tuples, a
later downgrade can fail because the partial unique index it tries to
recreate cannot be satisfied. Catch the IntegrityError and re-raise with
a guided message instructing the operator to remove the duplicate
`endpoints` rows before retrying. Document the caveat in the module
docstring so the limitation is discoverable.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@fregataa fregataa force-pushed the fix/BA-5974-remove-deployment-name-uniqueness branch from e998323 to 8f6d3a7 Compare May 8, 2026 01:53
@seedspirit seedspirit merged commit 9f7ee78 into main May 8, 2026
36 checks passed
@seedspirit seedspirit deleted the fix/BA-5974-remove-deployment-name-uniqueness branch May 8, 2026 03:51
@seedspirit seedspirit added this to the 26.4 milestone May 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp:common Related to Common component comp:manager Related to Manager component require:db-migration Automatically set when alembic migrations are added or updated size:L 100~500 LoC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants