← Back to Pull requests

feat: keep a PrefectServer until the resources that use it are deleted #409

Closed
unknown closed this pull request without merging on Nov 24, 2026 22:20 UTC
View on GitHub
unknown unknown commented on Nov 24, 2026 00:34 UTC
Author

Deleting a PrefectServer together with its work pools, work queues, deployments, or automations deleted the server's Deployment and Service right away. The other resources then couldn't reach the API to delete their Prefect objects, and stayed in Terminating for an hour.

PrefectServer now has the prefect.io/server-cleanup finalizer. While any resource in a watched namespace names the server in spec.server, without remoteApiUrl, the server keeps the finalizer:

  • The DeletionBlocked condition and a DependentsExist event name up to five of those resources.

  • A watch on the four kinds requeues the server when one is deleted. The server also checks again every 30 seconds.
  • The server waits for every resource that uses it, not only ones being deleted. Waiting only for resources with a deletion timestamp would race with kubectl delete -f server.yaml -f work-pool.yaml, which can reach the operator before the work pool is marked for deletion.

    Rollout caveats

  • watch: PrefectServers in Terminating with DeletionBlocked True. They wait for the resources that name them, with no time limit, which is the intended behavior.

  • rollback: earlier releases don't remove prefect.io/server-cleanup. After a downgrade, a deleted server stays in Terminating. #416 documents the fix.

  • no-op: a server already being deleted at upgrade doesn't get the finalizer, because the API server rejects new finalizers on it.
  • <details>
    <summary>Session context</summary>

    This came out of a review of the release-prep changes. The PRs above it in the stack handle the cases this one doesn't: namespace deletion, foreground deletion, and downgrades.

    </details>

    🤖 Generated with Claude Code

    Diff: 217 lines (+162 / -55) across 2 files Reviewer: chrisguidry Review duration: 1306m
    All Vouch review confidence checks passed
    Residual risk 0.16 = Change Risk (0.37) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.37 · 217 lines diff across 2 files
    0.37
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    56%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.322
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #409"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 36.7% (MEDIUM) · Higher = larger blast radius
    36.7%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 56.8% · Lower = rushed or shallow review
    56.8%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 15.9% · Safe to merge
    15.9%