Skip to content

feat(BA-5278): Use deploying-revision image for new route session creation#10271

Merged
HyeockJinKim merged 17 commits into
mainfrom
BA-5278
Mar 19, 2026
Merged

feat(BA-5278): Use deploying-revision image for new route session creation#10271
HyeockJinKim merged 17 commits into
mainfrom
BA-5278

Conversation

@jopemachine
Copy link
Copy Markdown
Member

Summary

During rolling updates, new route sessions were incorrectly using the target revision image from deployment info rather than the image of the specific revision assigned to each route. This fix ensures that when provisioning a new session for a route, the image is resolved from the route's own revision record.

Changes

  • Add revision_id: uuid.UUID | None = None field to RouteData dataclass
  • Populate revision_id from RoutingRow.revision in both get_routes_by_endpoint and get_routes_by_statuses in db_source.py
  • Add revision_id parameter to fetch_deployment_context() in db_source.py; when provided, queries DeploymentRevisionRow with selectinload(image_row) and builds an ImageIdentifier from it instead of using deployment_info.target_revision()
  • Add revision_id parameter to fetch_deployment_context() in repository.py and pass it through to db_source
  • Pass revision_id=route.revision_id when calling fetch_deployment_context() in _provision_route() inside the route executor

Testing

  • Verified pre-commit checks (ruff format, ruff check, visibility) pass with no errors
  • Rolling update integration test can be used to confirm new routes use the correct revision image

Related Issues

Fixes BA-5278

Copilot AI review requested due to automatic review settings March 17, 2026 04:33
@jopemachine jopemachine added the type:bug Reports about that are not working label Mar 17, 2026
@github-actions github-actions Bot added size:M 30~100 LoC comp:manager Related to Manager component labels Mar 17, 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

Fixes a bug where new route sessions during rolling updates used the deployment's target revision image instead of the image from the specific revision assigned to each route.

Changes:

  • Added revision_id field to RouteData and populated it from RoutingRow.revision in both route query methods
  • Extended fetch_deployment_context() with an optional revision_id parameter to resolve the image from a specific revision's DB row
  • Passed revision_id through from _provision_route() to ensure each route uses its own revision's image

Reviewed changes

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

File Description
types/endpoint.py Added revision_id optional field to RouteData dataclass
db_source.py Populated revision_id in route queries; added revision-specific image resolution logic in fetch_deployment_context()
repository.py Passed revision_id parameter through to db_source.fetch_deployment_context()
executor.py Passed route.revision_id when calling fetch_deployment_context()

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

You can also share your feedback on Copilot code review. Take the survey.

Comment thread src/ai/backend/manager/repositories/deployment/db_source/db_source.py Outdated
@jopemachine jopemachine changed the title fix: Use deploying revision image for new route session creation fix(BA-5278): Use deploying-revision image for new route session creation Mar 17, 2026
@github-actions github-actions Bot added size:L 100~500 LoC and removed size:M 30~100 LoC labels Mar 17, 2026
@jopemachine jopemachine marked this pull request as draft March 17, 2026 04:42
@jopemachine jopemachine modified the milestones: 26.3, 26.4 Mar 17, 2026
@jopemachine jopemachine marked this pull request as ready for review March 17, 2026 05:43
@jopemachine jopemachine requested a review from a team March 17, 2026 05:44
Comment thread src/ai/backend/manager/repositories/deployment/db_source/db_source.py Outdated
Comment thread src/ai/backend/manager/repositories/deployment/repository.py Outdated
@jopemachine jopemachine changed the title fix(BA-5278): Use deploying-revision image for new route session creation feat(BA-5278): Use deploying-revision image for new route session creation Mar 18, 2026
Comment thread src/ai/backend/manager/data/deployment/types.py Outdated
jopemachine and others added 7 commits March 19, 2026 11:49
During rolling updates, new route sessions were incorrectly using the
target revision image from deployment_info instead of the image associated
with the specific revision assigned to each route. This caused new sessions
to use the old revision's image when a rolling update was in progress.

- Add `revision_id` field to `RouteData` to carry per-route revision info
- Populate `revision_id` from `RoutingRow.revision` in both `get_routes_by_endpoint`
  and `get_routes_by_statuses` in db_source
- Add `revision_id` parameter to `fetch_deployment_context` in db_source and
  repository; when provided, resolve the image from that revision's DB row via
  `selectinload(DeploymentRevisionRow.image_row)` instead of falling back to
  `deployment_info.target_revision()`
- Pass `revision_id=route.revision_id` when calling `fetch_deployment_context`
  in `_provision_route` inside the route executor
Verify that _provision_route passes route.revision_id to
fetch_deployment_context so the correct revision's image is used
for session creation.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Comment on lines +783 to +792
# Build model_revisions list from loaded revision rows
if "revisions" in instance_state(self).dict and self.revisions:
model_revisions: list[ModelRevisionSpec] = []
for rev_row in self.revisions:
if rev_row.image_row is None:
continue
if rev_row.id == self.current_revision or rev_row.id == self.deploying_revision:
model_revisions.append(self._build_revision_spec(rev_row))
if model_revisions:
info = self._to_deployment_info_with_revisions(model_revisions)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The code for checking the string key doesn't look great, but since it seems to be an existing issue, I'll leave it for now.

@HyeockJinKim HyeockJinKim merged commit 9968847 into main Mar 19, 2026
33 checks passed
@HyeockJinKim HyeockJinKim deleted the BA-5278 branch March 19, 2026 05:18
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:L 100~500 LoC type:bug Reports about that are not working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants