Skip to content

Undeploy pipeline before deletion to stop agents#5

Merged
TerrifiedBug merged 1 commit intomainfrom
fix/undeploy-on-pipeline-delete
Mar 4, 2026
Merged

Undeploy pipeline before deletion to stop agents#5
TerrifiedBug merged 1 commit intomainfrom
fix/undeploy-on-pipeline-delete

Conversation

@TerrifiedBug
Copy link
Owner

No description provided.

@greptile-apps
Copy link

greptile-apps bot commented Mar 4, 2026

Greptile Summary

This PR adds a graceful undeploy step before pipeline deletion. When a deployed pipeline is deleted, it now sets isDraft: true and deployedAt: null before removing the database record, ensuring agents stop the pipeline on their next config poll rather than continuing to run a deleted pipeline.

Key Changes:

  • Added conditional undeploy update before prisma.pipeline.delete() in the delete mutation
  • Checks existing.deployedAt to only undeploy if the pipeline was actually deployed
  • Maintains existing authorization (withTeamAccess("EDITOR")) and audit logging (withAudit)

Implementation Notes:

  • The undeploy and delete operations are not wrapped in a transaction, which is acceptable - if deletion fails, the pipeline remains in an undeployed state that can be manually recovered
  • Agents polling between undeploy and delete will gracefully stop the pipeline and handle the subsequent missing pipeline on the next poll

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • Simple, focused change that addresses a real operational issue. The code follows established patterns, uses proper middleware (withTeamAccess, withAudit), and includes a clear explanatory comment. The undeploy-before-delete approach is sound and the edge cases (non-deployed pipelines, system pipelines) are already handled by existing checks.
  • No files require special attention

Important Files Changed

Filename Overview
src/server/routers/pipeline.ts Added undeploy step before deletion to gracefully stop agents - clean implementation with proper authorization and audit logging

Last reviewed commit: bd5b8d4

@TerrifiedBug TerrifiedBug merged commit 25adbcd into main Mar 4, 2026
11 checks passed
@TerrifiedBug TerrifiedBug deleted the fix/undeploy-on-pipeline-delete branch March 4, 2026 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant