Add DeploymentPolicy GQL API
- Dominant language
- Python
- Stars
- 670
- Forks
- 183
- Avg merge
- 17h 7m
- Merged PRs (30d)
- 358
Description
## Overview
Create GraphQL API for DeploymentPolicy (deployment strategy configuration).
**Note:** AutoScalingRule API already exists in `auto_scaling_rule.py`. This issue focuses only on DeploymentPolicy.
## Background
`DeploymentPolicyRow` exists in `src/ai/backend/manager/models/deployment_policy.py` with:
- `strategy`: ROLLING or BLUE_GREEN
- `strategy_spec`: RollingUpdateSpec or BlueGreenSpec (JSONB)
- `rollback_on_failure`: boolean
## Tasks
### 1. Create GraphQL Types
```
enum DeploymentStrategyType {
ROLLING
BLUE_GREEN
}
type RollingUpdateConfig {
maxSurge: Int!
maxUnavailable: Int!
}
type BlueGreenConfig {
previewReplicas: Int!
}
union StrategyConfig = RollingUpdateConfig | BlueGreenConfig
type DeploymentPolicy {
id: ID!
strategy: DeploymentStrategyType!
strategyConfig: StrategyConfig!
rollbackOnFailure: Boolean!
createdAt: DateTime!
updatedAt: DateTime!
}
```
### 2. Implement Query
```
deploymentPolicy(deploymentId: ID!): DeploymentPolicy
```
### 3. Implement Mutations
```
createDeploymentPolicy(input: CreateDeploymentPolicyInput!): CreateDeploymentPolicyPayload
updateDeploymentPolicy(input: UpdateDeploymentPolicyInput!): UpdateDeploymentPolicyPayload
deleteDeploymentPolicy(input: DeleteDeploymentPolicyInput!): DeleteDeploymentPolicyPayload
```
### 4. Input Types
```
input RollingUpdateConfigInput {
maxSurge: Int
maxUnavailable: Int
}
input BlueGreenConfigInput {
previewReplicas: Int
}
input CreateDeploymentPolicyInput {
deploymentId: ID!
strategy: DeploymentStrategyType!
rollingUpdateConfig: RollingUpdateConfigInput
blueGreenConfig: BlueGreenConfigInput
rollbackOnFailure: Boolean
}
input UpdateDeploymentPolicyInput {
deploymentId: ID!
strategy: DeploymentStrategyType
rollingUpdateConfig: RollingUpdateConfigInput
blueGreenConfig: BlueGreenConfigInput
rollbackOnFailure: Boolean
}
```
## File Location
`src/ai/backend/manager/api/gql/model_deployment/deployment_policy.py`
## Acceptance Criteria
- [ ] DeploymentPolicy type with strategy configuration
- [ ] Query for fetching policy by deployment ID
- [ ] CRUD mutations for policy management
- [ ] Unit tests
JIRA Issue: BA-3428
Contributor guide
Assessment
This issue has not been assessed yet.