feat: make init_deployment api support compute_unit

This commit is contained in:
icecheng 2025-10-28 10:10:53 +08:00
parent 6b9bdfb205
commit ad3b2ea938
2 changed files with 6 additions and 1 deletions

View File

@ -25,6 +25,7 @@ class Deployment(Document):
deployment_git_url: str
deployment_git_sha256: str
deployment_reason: str
compute_unit: Optional[int] = None # None for old data
deployment_app_url: str = "" # URL to access the deployed application, keep it empty to be filled later
deployed_by: str
@ -46,6 +47,7 @@ class InitDeploymentRequest(BaseModel):
user_id: str
reason: str = "not provided"
ttl_hours: int = -1
compute_unit: Optional[int] = 0
class CheckDeploymentStatusRequest(BaseModel):
product_id: str
@ -85,4 +87,5 @@ class DevOpsReconcileRequest(BaseModel):
commit_sha256: Optional[str] = None
target_env: Literal["alpha", "prod"]
ttl_control: bool = False
ttl: int = 10800
ttl: int = 10800
compute_unit: Optional[int] = 0

View File

@ -58,6 +58,7 @@ class DeploymentService:
deployed_by = request.user_id,
created_at = datetime.now(),
updated_at = datetime.now(),
compute_unit = request.compute_unit,
)
await self._start_deployment(deployment)
@ -182,6 +183,7 @@ class DeploymentService:
ttl_control=deployment.deployment_ttl_hours > 0,
ttl=10800 if deployment.deployment_ttl_hours < 0 else deployment.deployment_ttl_hours * 60 * 60,
commit_sha256=deployment.deployment_git_sha256,
compute_unit=deployment.compute_unit
)
# send request to reoncile service
async with httpx.AsyncClient() as client: