feat(BA-5401): Ensure every deployment has a default rolling deployment policy#10497
feat(BA-5401): Ensure every deployment has a default rolling deployment policy#10497seedspirit merged 20 commits intomainfrom
Conversation
e5d2d80 to
b3201e9
Compare
|
This PR should be merged after updating the default values following #10563. |
There was a problem hiding this comment.
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…e migrations - Add ON DELETE CASCADE FK from deployment_policies.endpoint → endpoints.id so endpoint deletion automatically cascades to its policy - Fix model serving create_endpoint_validated() to create a default rolling deployment policy (was missing, would violate NOT NULL constraint) - Merge two migration scripts into one - Fix Mapped[UUID | None] → Mapped[UUID] for deployment_policy_id (NOT NULL) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ints - Remove _migration_a1b2c3d4e5f6_created_policies tracking table - Create default policies for all endpoints (including destroyed) to ensure deployment_policy_id NOT NULL constraint holds - Simplify downgrade by removing policy cleanup (column drop suffices) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…tion Revision ID a1b2c3d4e5f6 was already used by rename_scaling_group_to_resource_group migration, causing duplicate head. Rename to 930e9f2dd502. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ragment - Fix RBACElementRef import path (repositories.base.rbac.element_ref → data.permission.types) - Rebase migration down_revision to 3727dd0927cf (resolve diverged heads) - Add news fragment for towncrier Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…lassmethod Add DeploymentPolicyCreatorSpec.build_default() to eliminate duplicated default rolling policy creation logic across 3 call sites. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Remove _get_endpoint_join_condition and _get_endpoint_deployment_policy_join_condition, replaced by FK-based relationships. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…te pattern Endpoint is inserted before its policy in the same transaction, so NOT NULL on deployment_policy_id is not feasible (NOT NULL is checked at INSERT time, unlike DEFERRABLE FK). Column stays nullable; application code always sets it immediately after policy creation. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…t_policies.endpoint FK Remove the redundant EndpointRow.deployment_policy_id reverse FK that created a circular dependency with DeploymentPolicyRow.endpoint. The single FK from deployment_policies.endpoint → endpoints.id with CASCADE is sufficient for the 1:1 relationship and ensures policy cleanup on endpoint deletion. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…constraint Migration fails if deployment_policies table contains rows referencing non-existent endpoints. Delete orphaned rows before adding the FK. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
… fix mapper init The EndpointRow.deployment_policy relationship used string-based foreign_keys which required DeploymentPolicyRow to be in the mapper registry at init time. Switch to primaryjoin with a lazy import function, matching the pattern used by all other relationships in EndpointRow. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…move stale merge script - Delete merge_930e9f2dd502_0a200d0fc480_f5338adb2de1.py (no longer needed after rebase) - Update 930e9f2dd502 down_revision to point to all current main heads (17b679c98b50, 6f8a4c0d2e3g, 7h4m7ygnaao1) so this single script both merges the diverged heads and applies the deployment policy FK migration Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…available=0% Align build_default and migration with the new IntOrPercent-based defaults. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
| await execute_rbac_entity_creator(db_sess, policy_creator) | ||
| policy_spec = spec.policy | ||
| else: | ||
| policy_spec = DeploymentPolicyCreatorSpec.build_default(endpoint.id) |
There was a problem hiding this comment.
If we define a class method that creates a CreatorSpec by injecting a policy—such as with_policy—wouldn’t that allow us to hide the if branches in the creation logic that handle situations where the policy is optional? Or is it more important to make the creation of the RBACEntityCreator more explicit in the service layer?
There was a problem hiding this comment.
Because the if statement is small and sufficiently readable, I think it does not seem to introduce any meaningful difference in terms of readability.
Resolves #10487 (BA-5401)
Summary
fk_deployment_policies_endpoint) fromdeployment_policies.endpoint→endpoints.idwithON DELETE CASCADETest plan
check-alembic-migrationsCI passedlint-and-typecheckCI passed🤖 Generated with Claude Code