runner: accept 200 reused re-registration from manager (closes #31) #32
No reviewers
Labels
No labels
Compat/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
blocked
draft
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
s1d3sw1ped/jiggablend!32
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/31-runner-reregister"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #31
Why
When a known runner (same fingerprint and API key) registers again, e.g. after a restart, the manager answers
200 OKwithreused: true(internal/manager/runners.go). The runner client ininternal/runner/api/manager.goonly accepted201 Created, so it treated the reuse as a failure and a restarted runner could never come back (0.0.10 through 0.0.13). This stalled render job 1 for about 10 hours.What changed
Registeraccepts both201(new runner) and200(reused runner). Every other status still errors as before, including the token-error path for 400/401.RegisterResponsenow also decodesreused. Both responses carryid, which is still what sets the runner ID, so a reused runner keeps its existing ID.id(<= 0) is now an error instead of quietly setting runner ID 0.Tests
New
internal/runner/api/register_test.go, using httptest managers:TestRegister_ReusedRunner200: 200 +reused:truesucceeds and returns/sets id 42.TestRegister_NewRunner201: 201 succeeds and sets the id.TestRegister_OtherStatusesError: 202, 204, 400, 401, 409, 500 all error and leave runner ID 0.TestRegister_SuccessWithoutIDErrors: 200/201 without an id errors.On the old code,
TestRegister_ReusedRunner200fails withregistration failed (status 200): {"id":42,...,"reused":true}. With the fix, all four pass.Risk / rollback
Client-side only, one function. Roll back by reverting this commit.
GO. This is the right fix for #31: the runner now takes the manager's 200 with reused:true as success and keeps the existing runner ID, while every other status still errors the same way as before. The new id <= 0 check is a nice guard against quietly running as runner 0.
The tests cover the actual restart case plus the 201 path, the error statuses, and a success body with no id, and CI is green on
f86161d. The head sits on the current develop tip, and it's client-side only with a one-commit revert.Not security-sensitive (no change to how the manager checks the key), so Linus can merge. After that, a release so ai1 can drop the 0.0.12-jerry1 hotfix.