Skip to content

feat: allow cancellation of queued deployments #139

Description

@dennisonbertram

Problem

When a deployment is triggered (via build or image deploy), there is no way to cancel it if it's still queued or in progress. CI/CD pipelines can trigger mistaken deploys, and the only option is to wait for completion or delete the service entirely.

Proposed Solution

POST /v1/services/{serviceID}/deployments/{deploymentID}/cancel

Cancels a queued or in-progress deployment. Returns 409 if the deployment is already completed or already cancelled.

Response:

{
  "id": "deploy-123",
  "status": "cancelled",
  "cancelled_at": "2026-03-22T10:00:00Z"
}

Behavior

  • Queued deployments: Set status to cancelled, remove from queue
  • In-progress deployments:
    • If building: cancel the build (send context cancellation)
    • If deploying container: stop the new container, keep the current one running
  • Completed/failed/cancelled: Return 409 Conflict

Implementation Notes

  • Add handler in internal/api/services.go or internal/api/builds.go
  • Use the deployment store's status field
  • For in-progress builds, use context cancellation (builds already support this via fix(tenant): cancel active builds during tenant suspension #88)
  • Record cancelled_at timestamp and cancelled_by (key ID from auth context)

Acceptance Criteria

  • POST /v1/services/{id}/deployments/{id}/cancel cancels queued deployments
  • In-progress builds are cancelled via context cancellation
  • Completed deployments return 409
  • cancelled_at and cancelled_by recorded
  • Current running service is not affected by cancellation
  • Unit tests for each deployment state transition
  • API reference updated

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions