Add Promote/Rollback GQL mutations
- Dominant language
- Python
- Stars
- 670
- Forks
- 183
- Avg merge
- 17h 7m
- Merged PRs (30d)
- 358
Description
## Overview
Create dedicated GraphQL mutations for revision promotion and rollback operations.
**Note:** Currently `updateModelDeployment` with `activeRevisionId` can change the active revision, but dedicated mutations provide better UX and can include validation logic.
## Tasks
### 1. Implement `promoteDeploymentRevision` mutation
Promote a specific revision to be the active revision.
```
input PromoteRevisionInput {
deploymentId: ID!
revisionId: ID!
}
type PromoteRevisionPayload {
deployment: ModelDeployment!
previousRevisionId: ID
promotedRevisionId: ID!
}
mutation {
promoteDeploymentRevision(input: PromoteRevisionInput!): PromoteRevisionPayload
}
```
**Logic:**
- Validate target revision exists and belongs to the deployment
- Validate revision is within `revision_history_limit`
- Set `endpoint.current_revision` to target revision
- Update `deployment_state` appropriately
- Handle traffic_status transitions for routes
### 2. Implement `rollbackDeployment` mutation
Rollback to a previous revision.
```
input RollbackDeploymentInput {
deploymentId: ID!
# One of the following must be provided:
stepsBack: Int # Number of revisions to go back (e.g., 1 = previous)
targetRevisionId: ID # Specific revision to rollback to
}
type RollbackDeploymentPayload {
deployment: ModelDeployment!
rolledBackFromRevisionId: ID
rolledBackToRevisionId: ID!
}
mutation {
rollbackDeployment(input: RollbackDeploymentInput!): RollbackDeploymentPayload
}
```
**Logic:**
- Validate target revision (by steps_back calculation or direct ID)
- Validate revision exists in history
- Set `current_revision` to target
- Update deployment_state to indicate rollback in progress
- Respect deployment policy (rolling_update vs blue_green)
## File Location
Add to `src/ai/backend/manager/api/gql/model_deployment/model_deployment.py` or create new `deployment_operations.py`
## Acceptance Criteria
- [ ] `promoteDeploymentRevision` mutation with validation
- [ ] `rollbackDeployment` mutation with steps_back and targetRevisionId support
- [ ] Proper error handling for invalid revisions
- [ ] Unit tests for both mutations
JIRA Issue: BA-3429
Contributor guide
Assessment
This issue has not been assessed yet.