Delete a deployment for a project. This will remove the HostingProjectModel record and clean up any associated resources.
(
self,
project_id: str,
orm: Session = Depends(get_orm_session),
)
| 395 | |
| 396 | class DeleteDeploymentView(BaseDeploymentView): |
| 397 | async def __call__( |
| 398 | self, |
| 399 | project_id: str, |
| 400 | orm: Session = Depends(get_orm_session), |
| 401 | ) -> StatusResponse: |
| 402 | """ |
| 403 | Delete a deployment for a project. |
| 404 | |
| 405 | This will remove the HostingProjectModel record and clean up any associated resources. |
| 406 | """ |
| 407 | project: HostingProjectModel = await self.get_hosting_project(orm, project_id) |
| 408 | |
| 409 | # Delete all Kubernetes resources associated with the deployment |
| 410 | # This includes deployments, services, ingress, and secrets |
| 411 | deployment_name = project_id # Use project_id as deployment name |
| 412 | namespace = project.namespace |
| 413 | |
| 414 | try: |
| 415 | success = delete_deployment_resources( |
| 416 | namespace=namespace, deployment_name=deployment_name, deployment_id=project_id |
| 417 | ) |
| 418 | |
| 419 | if not success: |
| 420 | logger.warning(f"Some Kubernetes resources failed to delete for project {project_id}") |
| 421 | # Continue with database deletion even if k8s cleanup had issues |
| 422 | except Exception as e: |
| 423 | logger.error(f"Error during Kubernetes cleanup for project {project_id}: {e}") |
| 424 | # Continue with database deletion even if k8s cleanup failed |
| 425 | |
| 426 | # Delete the HostingProjectModel record |
| 427 | orm.delete(project) |
| 428 | orm.commit() |
| 429 | |
| 430 | return StatusResponse( |
| 431 | success=True, |
| 432 | message="Deployment deleted successfully", |
| 433 | ) |
nothing calls this directly
no test coverage detected