Skip to content

feat(server): graceful drain + pod lifecycle (ADR-0070 D2) - #611

Merged
delete-cloud merged 1 commit into
mainfrom
feat/graceful-drain-helm-lifecycle
Jun 16, 2026
Merged

delete-cloud merged 1 commit into
mainfrom
feat/graceful-drain-helm-lifecycle

Conversation

@delete-cloud

Copy link
Copy Markdown
Owner

Why (ADR-0070 D2)

A rolling-update/restart (incl. the #606 config-checksum auto-roll) could SIGKILL the process before in-flight turns drained — the chart set no terminationGracePeriodSeconds (k8s default 30s) and no preStop. And graceful shutdown left in-flight turns in the wrong durable state.

What

Helm (values-driven lifecycle:):

  • terminationGracePeriodSeconds (default 60) rendered on the pod spec.
  • gated container preStop sleep (preStopSleepSeconds default 5; 0 disables) for drain headroom.

App — fix a real shutdown-semantics gap found during implementation:

  • Graceful shutdown cancelled the active turn → run status cancelled (indistinguishable from a user cancel), and startup recovery only rewrites still-running runs to interrupted — so the run stayed cancelled.
  • lifespan now calls shutdown_session_runtime(interrupt_active_turn=True); that path rewrites the active stopped run (running/cancelling/cancelled) to interrupted with reclaimable metadata. Idle cleanup (D1) keeps the default — no interrupt marking, no deletion.

Test

  • test_helm_deployment_sets_graceful_drain (defaults / overrides / preStop disable)
  • test_lifespan_shutdown_marks_active_turn_interrupted
  • Gate: uv run pytest tests/deploy/test_helm_chart.py tests/ui/test_http_server.py tests/ui/test_session_manager_public_api.py → 388 passed.

Completes the ADR-0070 series (#608 docs, #610 D1). ArgoCD (#71) implementation is intentionally deferred until D1+D2 are live.

🤖 Generated with Claude Code

So a rolling-update/restart (incl. the #606 config-checksum auto-roll) drains
in-flight turns instead of being SIGKILLed.

Helm: values-driven lifecycle — terminationGracePeriodSeconds (default 60, was
the k8s default 30) + a gated preStop sleep (preStopSleepSeconds default 5, 0
disables). Rendered in deployment.yaml.

App: graceful shutdown previously cancelled the in-flight turn (run status
cancelled, indistinguishable from a user cancel) and startup recovery only
rewrites still-running runs to interrupted, so the run stayed cancelled.
lifespan now calls shutdown_session_runtime(interrupt_active_turn=True); that
path rewrites the active stopped run to interrupted with reclaimable metadata.
Idle cleanup keeps the default (no interrupt marking).

Tests: test_helm_deployment_sets_graceful_drain; test_lifespan_shutdown_marks_active_turn_interrupted. Gate: 388 passed.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@delete-cloud, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 5 minutes and 41 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 6b32cd51-426c-479b-a41f-b86303931400

📥 Commits

Reviewing files that changed from the base of the PR and between aa92afc and 72eb120.

📒 Files selected for processing (6)
  • coding-agent/helm/templates/deployment.yaml
  • coding-agent/helm/values.yaml
  • coding-agent/src/coding_agent/server/http_server.py
  • coding-agent/src/coding_agent/server/session_manager.py
  • coding-agent/tests/deploy/test_helm_chart.py
  • coding-agent/tests/ui/test_http_server.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/graceful-drain-helm-lifecycle

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@delete-cloud
delete-cloud merged commit e1c8fbc into main Jun 16, 2026
2 checks passed
@delete-cloud
delete-cloud deleted the feat/graceful-drain-helm-lifecycle branch June 16, 2026 08:19
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