Repository navigation
fix(nodepool): count a health check from when it was asked - #5626
Conversation
The health checker stamped each check with the time its answer arrived. The planner drops a reservation once a check is newer than it, so a start reserved while a check was on its way back stopped counting even though the node answered before the start reached it. The check is now stamped with the time its request was sent. Closes Silo-Server#5447 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Warning Review limit reachedThis organization requires a seat for paid usage-based reviews, including automatic and on-demand reviews. Ask an admin to assign a seat or enable paid usage-based reviews for users without a seat in Billing. Next included review available in 10 minutes. View limit details
|
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
The pools recorded a check at the time its request was sent, but the database stamped last_health_check with NOW(), so a pool reloaded from it drew the reservation boundary at the answer's time again. CheckNodeReport now records the ask time on the report, and the sweep, the recheck, the admin check and the stored row all use it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
… test last_health_check is now when the check was sent, so the stats and network access a check writes can be up to its five-second timeout newer than it. The admin API doc, the Node and storage view comments, and the web type comment said they were never fresher; they now say they come from that check's answer. The AskedAt comment also names the window the change leaves: a start reserved before the check but still in transit. The reservation test's node handler waited on its gate alone, so a test that failed before releasing it hung in httptest.Server.Close. It now also returns when the request is cancelled. The DB test drops its half that covered a report without an ask time, which no caller builds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Quick104
left a comment
There was a problem hiding this comment.
Review of b156b2c. Using the time the check was sent is the right boundary, and every writer now uses it: the sweep, the recheck, the admin check and the stored row. TestReservationMadeDuringAHealthCheckKeepsCounting fails on the base for the reported reason (the node's load reads 0 jobs) and passes here. Four small findings below. I'm fixing all four in a commit on this branch, so there's no need to change anything yourself.
🤖 Claude Code (claude-opus-5-5)
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
Maintainer review summaryReviewed b156b2c; fixes pushed in 1ee1814, then main merged. The head is now e80e36a. The change fixes #5447 at the right place. A health check is now stamped with the time its request was sent, the only moment a report and a planner reservation can be compared. The sweep, the recheck, the admin check, and the stored Fixed on this branch (1ee1814)
Left as it was
Checks
Evidence: https://evidence.siloserver.org/r/silo-server/pr-5626-review/ Fit: 9/10 · Readiness: 9/10 — ready (assuming CI is green) Fit: a bounded logic fix in the server's own load accounting, with no new setting, field, or surface. It errs toward spreading load, which suits a cluster where a node can go down mid-stream. Readiness: the bug's test fails on the base, the review fixes are verified, the validation board check ran, and nothing this PR causes is left open. 🤖 Claude Code (claude-opus-5-5) |
Keeps both appended db-contracts lines (Silo-Server#5626's nodepool test and this PR's webhooksync test). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Depends on: none. Merge order: none. Follows #5446 (merged), which closed the larger part of this gap.
Problem
Closes #5447
Validation tasks: none
Other clients: Apple N/A, Android N/A, Roku N/A (API server's node planner)
publishHealth(internal/nodepool/health.go) stamped each health check withtime.Now()when the answer arrived.pendingReservations(internal/nodepool/planner.go) drops a reservation once the node'sLastHealthCheckis after the reservation'screatedAt. So a reservation made while a check was in flight stopped counting when that check's answer arrived, even if the node answered before the start reached it. Both the total and the per-kind load then missed the job until the next check, and a burst of starts could pick the same node.Approach
This is the first, narrower fix the issue lists.
CheckNodeReportrecords the time just before it sends the health request, asHealthReport.AskedAt. The sweep (checkOne), the recheck (recheckOne) and the admin check (applyHealthToPools) apply the report with that time asLastHealthCheck. A report can only include work that reached the node before it was asked, so a reservation made after that keeps counting until a later check.heldAtCapacity) compares the same field, so a refusal made after a check was sent is no longer cleared by that check's answer either.UpdateHealthReportstores the same time aslast_health_check, so a pool reloaded from the database draws the same boundary (fix(nodepool): count a health check from when it was asked #5626 review). A report without an ask time still storesNOW().Validation
TestReservationMadeDuringAHealthCheckKeepsCounting:effectiveJobsstill counts the reservation.TestHealthReportStoresTheTimeItWasAskedDB(Postgres) checks that the stored time is the ask time. With b62c3f1'srepository.go, it stores the write time. Added toscripts/ci/db-contracts.txt.last_health_check, made the reservation test return instead of hanging when it fails early, and merged main.health.goandunreachable.go, the load drops to 0 jobs (output under Evidence).go test -count=1 ./internal/nodepool/ ./internal/api/handlers/ ./internal/playback/...passes against a local Postgres 18, and the new test passes with-race.lint-changed: 0 issues.Evidence
Evidence: https://evidence.siloserver.org/r/silo-server/pr-5626-review/
No screen changes. Results of
go test -count=1 -v -run TestReservationMadeDuringAHealthCheckKeepsCounting ./internal/nodepool/.Before (
health.goandunreachable.gofrom main bc17dc0):After (this branch at b62c3f1; the test also passes at b156b2c):
Risks
Checklist
Council review
Rounds: 1, reviewed b156b2c
Fixed: the test hang, the comment on the window this leaves, and the half of the DB test that covered an unused fallback. Answered: all three members flagged that an older health report can overwrite a newer one (the admin check doesn't take the per-node check lock, and the database write has no freshness check). That predates this change, and the report now carries its own older time, so it errs toward counting more load. Clock skew between API servers replaces the earlier skew between API servers and Postgres, so it is not new.
AI Disclosure
🤖 Generated with Claude Code
Note
Count health checks from when the check was asked, not when applied
Adds
AskedAttonodepool.HealthReportand aCheckedAt()method that returns it, falling back to the current time when unset. CheckNodeReport captures a timestamp before running the check and attaches it to the report.Repository.UpdateHealthReport,HealthChecker.publishHealth,NodeHandler.applyHealthToPools) now use the report's check time instead of the time the result is applied. Updates without a report still store the current time.last_health_checkrecords when the check was sent and the sample can be up to 5 seconds newer.TestHealthReportStoresTheTimeItWasAskedDB.last_health_checkvalues shift to the ask time, so consumers comparing it to the check's five-second timeout window should checkRepository.updateHealthand the admin API docs.Macroscope summarized e80e36a.