Skip to content

Derive the shutdown deadline from the run context - #17

Merged
mrrobertkent merged 1 commit into
mainfrom
shutdown-context
Oct 8, 2026
Merged

mrrobertkent merged 1 commit into
mainfrom
shutdown-context

Conversation

@mrrobertkent

@mrrobertkent mrrobertkent commented Oct 8, 2026 •

Copy link
Copy Markdown
Owner

Shutdown now uses context.WithoutCancel(ctx) instead of context.Background(): the deadline keeps the run context's values while ignoring its cancellation, which is what triggered the shutdown.

Summary by CodeRabbit

  • Bug Fixes
    • During shutdown, the configured timeout is now applied using the run context with cancellation removed. This preserves context values while allowing shutdown to proceed independently of cancellation, instead of starting from a background context.

@coderabbitai

coderabbitai Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: mrrobertkent/hookgate/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d7baaff1-ef4b-4032-8513-31b702d60cd9
📥 Commits

Reviewing files that changed from the base of the PR and between 1ac44ac and d030288.

📒 Files selected for processing (1)
  • internal/gateway/gateway.go

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.


📝 Walkthrough

Walkthrough

Run now derives the shutdown-timeout context from ctx with cancellation removed. It retains the configured shutdown timeout.

Changes

Shutdown Context

Layer / File(s) Summary
Shutdown timeout context
internal/gateway/gateway.go
Run now passes context.WithoutCancel(ctx) to the shutdown-timeout context creation. The configured timeout remains unchanged.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~5 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to d0302

Shutdown remains bounded by its configured timeout while preserving caller context values. No material merge risk is evident beyond normal checks.

Security Architecture Review

Security architecture risk: ⚪ Minimal · up to d0302

The configured shutdown timeout and cancellation-triggered drain remain intact. Preserved context values do not gain new authority in the inspected server shutdown path, and no material security risk was found to be introduced or worsened.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The changed behavior is scoped to shutdown coordination for the existing primary and administrative listeners. The comparison shows no new listener, request entrypoint, or downstream authority granted by retaining caller values.

Trust Boundaries and Controls

  • inferred — Cancellation detachment does not weaken the prior shutdown control: Background already ignored caller cancellation. In the inspected TCP shutdown implementation, the context governs waiting through Done and Err; inherited values are not used to authorize operations.

Resilience and Maintainability Implications

  • observed — The existing drain test observes cancellation, successful request handling during drain, and Run's return. It does not directly prove value retention, detached cancellation, deadline expiry under a blocked request, or recovery from partial shutdown failure.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check Warning The description explains the implementation and its purpose, but it omits the required "What changes for users" section and the checklist, including test and documentation status. Add the required "## What changes for users" section with a one- or two-sentence release note. Include the checklist and mark each item as applicable or complete, including test, vet, race, formatting, and documentation status.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: deriving the shutdown deadline from the run context.
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@sonarqubecloud

sonarqubecloud Bot commented Oct 8, 2026

Copy link
Copy Markdown

@gitar-bot

gitar-bot Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Code Review ✅ Approved

🟡 Medium risk · Passing run-context values into server and admin shutdown may change context-aware cleanup behavior, while cancellation remains detached and timeout-bound.

Shutdown deadline now derives from the run context via context.WithoutCancel(ctx) instead of context.Background(), keeping the context's values while ignoring the cancellation that triggered shutdown. No issues found.

Review coverage

📋 Rules No rules evaluated

🧪 Functional validation Not enabled · Set up

Options

Auto-apply is off → Gitar will not commit updates to this branch.
Display: compact → Counting what did not apply, without listing it.

Comment with these commands to change the behavior for this request:

Auto-apply Compact
gitar auto-apply:on         
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar

@mrrobertkent
mrrobertkent merged commit 8c7b949 into main Oct 8, 2026
12 checks passed
@mrrobertkent
mrrobertkent deleted the shutdown-context branch October 8, 2026 22:32
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