fix(BA-5974): remove deployment name uniqueness constraint#11507
Merged
seedspirit merged 5 commits intomainfrom May 8, 2026
Merged
fix(BA-5974): remove deployment name uniqueness constraint#11507seedspirit merged 5 commits intomainfrom
seedspirit merged 5 commits intomainfrom
Conversation
fregataa
added a commit
that referenced
this pull request
May 7, 2026
Contributor
There was a problem hiding this comment.
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
DeploymentNameAlreadyExistsexception. - 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.
Member
|
Would it be better to remove the unique constraint entirely rather than applying it per scope? |
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>
e998323 to
8f6d3a7
Compare
seedspirit
approved these changes
May 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ix_endpoints_unique_name_when_activeon(name, domain, project)and the application-level_check_endpoint_name_existspre-check, so deployment names are no longer unique within a project.domain, project) did not match themy_deploymentslist 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.DeploymentNameAlreadyExistsexception and the duplicate-name test. Routing keys onroute_id, and the inference session name templatef"{endpoint.name}-{route_id}"already disambiguates downstream.Test plan
\d endpointsno longer listsix_endpoints_unique_name_when_active.created_user) and confirm both succeed.my_deploymentsand project-scoped list queries return both rows as expected.lifecycle_stage NOT IN ('destroying', 'destroyed').Resolves BA-5974