Skip to content

fix(pegboard): validate drain_grace_period < request_lifespan#4998

Open
abcxff wants to merge 1 commit into05-06-fix_rivetkit_bind_methods_through_createwritethroughproxyfrom
05-07-fix_pegboard_validate_drain_grace_period_request_lifespan
Open

fix(pegboard): validate drain_grace_period < request_lifespan#4998
abcxff wants to merge 1 commit into05-06-fix_rivetkit_bind_methods_through_createwritethroughproxyfrom
05-07-fix_pegboard_validate_drain_grace_period_request_lifespan

Conversation

@abcxff
Copy link
Copy Markdown
Contributor

@abcxff abcxff commented May 7, 2026

when drain_grace_period >= request_life_span, we get undefined behaviour. This enforces this on the server side befoe pool config is upserted

Copy link
Copy Markdown
Contributor Author

abcxff commented May 7, 2026

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@railway-app
Copy link
Copy Markdown

railway-app Bot commented May 7, 2026

🚅 Deployed to the rivet-pr-4998 environment in rivet-frontend

Service Status Web Updated (UTC)
website ✅ Success (View Logs) Web May 9, 2026 at 1:50 am
mcp-hub ✅ Success (View Logs) Web May 7, 2026 at 8:18 pm
kitchen-sink ❌ Build Failed (View Logs) Web May 7, 2026 at 8:18 pm
frontend-cloud ❌ Build Failed (View Logs) Web May 7, 2026 at 8:18 pm
frontend-inspector ❌ Build Failed (View Logs) Web May 7, 2026 at 8:18 pm
ladle ❌ Build Failed (View Logs) Web May 7, 2026 at 8:15 pm

@claude
Copy link
Copy Markdown
Contributor

claude Bot commented May 7, 2026

Code Review

Overview

This PR adds a validation guard in pegboard_runner_config_upsert to reject serverless runner configs where drain_grace_period >= request_lifespan. The change is minimal and targeted: it destructures request_lifespan from the match arm and inserts a single comparison check before the existing drain_grace_period > actor_stop_threshold check.


What's Good

  • Follows existing patterns exactly. The error type, format style, and placement within the validation block are consistent with the surrounding checks (e.g. slots_per_runner == 0, header length).
  • Clear error message. The format string surfaces both values and their units ({drain_grace_period}s >= {request_lifespan}s), giving operators an actionable diagnostic.
  • Correct comparison. Both fields are u32 seconds, and >= is the right operator since equal values (e.g. both 30s) are also semantically invalid — the drain would expire at the exact moment the request does, leaving no margin.

Issues / Suggestions

Missing test coverage

No test is added for this new validation path. This is the most significant gap. The PR description checklist item for tests is unchecked. Suggested: add a test that calls pegboard_runner_config_upsert with drain_grace_period == request_lifespan and with drain_grace_period > request_lifespan, verifying RunnerConfig::Invalid is returned in both cases.

Edge case: request_lifespan = 0

If a caller passes request_lifespan = 0, the new check drain_grace_period >= 0 is always true for a u32, so the validation correctly rejects it — but the error message (must be less than request_lifespan (Xs >= 0s)) will be confusing. Consider whether request_lifespan > 0 should be validated explicitly with its own error before this check, similar to the slots_per_runner == 0 guard.

PR is still a draft

The description template is unfilled and all checklist items are unchecked. Nothing blocking from a code standpoint, but worth completing before requesting review.


Summary

The logic is correct and well-placed. Main asks before merging: add a test covering the new validation branch, and consider an explicit request_lifespan > 0 guard to avoid a misleading error message when that field is zero.

@abcxff abcxff changed the base branch from 05-06-_slop_fix_rivetkit_remove_async_drizzle_db_proxy to graphite-base/4998 May 7, 2026 20:16
@abcxff abcxff force-pushed the 05-07-fix_pegboard_validate_drain_grace_period_request_lifespan branch from 9b5f655 to 56af1d1 Compare May 7, 2026 20:16
@abcxff abcxff changed the base branch from graphite-base/4998 to 05-06-fix_rivetkit_bind_methods_through_createwritethroughproxy May 7, 2026 20:16
@abcxff abcxff marked this pull request as ready for review May 7, 2026 20:18
@abcxff abcxff requested a review from MasterPtato May 7, 2026 20:23
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