fix: cancel in-progress deploy on new webhook trigger (closes #38) #53

Closed
clawbot wants to merge 1 commits from (deleted):fix/cancel-deploy-on-webhook into main
Collaborator

When a webhook-triggered deploy starts for an app that already has a deploy in progress, the new deploy now cancels the existing one via context cancellation, waits for the lock to be released, and then starts the new deploy.

Changes

  • Add per-app context cancellation (appCancels sync.Map) to deploy.Service
  • Deploy() creates a cancellable context and registers it for the app
  • Add CancelAppDeploy() method to cancel an in-progress deploy
  • Add ErrDeployCancelled sentinel error for cancelled deploys
  • Handle context cancellation in build and deploy phases, marking deployments as failed with a clear cancellation message
  • Webhook triggerDeployment() now cancels in-progress deploys and retries until the lock is released (up to 30 attempts with 2s delay)
  • Added tests for cancellation behavior

fixes #38

When a webhook-triggered deploy starts for an app that already has a deploy in progress, the new deploy now cancels the existing one via context cancellation, waits for the lock to be released, and then starts the new deploy. ## Changes - Add per-app context cancellation (`appCancels sync.Map`) to `deploy.Service` - `Deploy()` creates a cancellable context and registers it for the app - Add `CancelAppDeploy()` method to cancel an in-progress deploy - Add `ErrDeployCancelled` sentinel error for cancelled deploys - Handle context cancellation in build and deploy phases, marking deployments as failed with a clear cancellation message - Webhook `triggerDeployment()` now cancels in-progress deploys and retries until the lock is released (up to 30 attempts with 2s delay) - Added tests for cancellation behavior fixes #38
sneak was assigned by clawbot 2026-02-16 07:13:42 +01:00
clawbot added 1 commit 2026-02-16 07:13:43 +01:00
When a webhook-triggered deploy starts for an app that already has a deploy
in progress, the new deploy now cancels the existing one via context
cancellation, waits for the lock to be released, and then starts the new
deploy.

Changes:
- Add per-app context cancellation (appCancels sync.Map) to deploy.Service
- Deploy() creates a cancellable context and registers it for the app
- Add CancelAppDeploy() method to cancel an in-progress deploy
- Add ErrDeployCancelled sentinel error for cancelled deploys
- Handle context cancellation in build and deploy phases, marking
  deployments as failed with a clear cancellation message
- Webhook triggerDeployment() now cancels in-progress deploys and retries
  until the lock is released (up to 30 attempts with 2s delay)

fixes #38
Author
Collaborator

CI Results

Tests

All tests pass (make test)

Lint

No new lint issues (golangci-lint run ./...)

Note: 1 pre-existing lint issue in internal/handlers/tail_validation_test.go (testpackage) — not related to this PR.

## CI Results ### Tests ✅ All tests pass (`make test`) ### Lint ✅ No new lint issues (`golangci-lint run ./...`) Note: 1 pre-existing lint issue in `internal/handlers/tail_validation_test.go` (testpackage) — not related to this PR.
clawbot closed this pull request 2026-02-16 07:14:13 +01:00
Author
Collaborator

Closing as duplicate — PR #52 already addresses this issue with a cleaner approach.

Closing as duplicate — PR #52 already addresses this issue with a cleaner approach.

Pull request closed

Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: sneak/upaas#53
No description provided.