fix(nodes): prevent cross-worker lifecycle races - #794
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (6)
Included review availability: Your plan includes up to 8 reviews per rolling hour; 7 remain after this review. WalkthroughNode replacement now supports disabling remote shutdown during synchronization. Concurrent connection contenders return ChangesNode lifecycle coordination
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to This change narrows cross-worker node lifecycle behavior and handles lease contention without overwriting the lease owner’s result; no actionable merge-blocking risk remains after normal checks and review. Sequence Diagram(s)sequenceDiagram
participant manager_sync
participant NodeManager
participant OldController
manager_sync->>NodeManager: update_node(remote_stop=False)
NodeManager->>OldController: shutdown(remote_stop=False)
NodeManager-->>manager_sync: replacement controller
sequenceDiagram
participant connect_node
participant NodeStartup
participant AttachRetry
connect_node->>NodeStartup: start node
NodeStartup-->>connect_node: NodeAPIError(409, "already in progress")
connect_node->>AttachRetry: attempt attachment
AttachRetry-->>connect_node: unsuccessful
connect_node-->>connect_node: return None
Possibly related PRs
Suggested labels: Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
|
@coderabbitai review |
✅ Action performedReview finished.
|
Summary
Root cause
In multi-worker deployments, a worker receiving an
upsertorconnectsynchronization event replaced its local controller and remotely stopped the node. That raced the origin worker's successful start. Concurrent contenders then persistedNode lifecycle operation already in progressover the owner's eventual result.Verification
ruff check .pytest tests/test_node_manager_sync.py tests/test_node_manager.py tests/test_connect_concurrency.py -q(13 passed)pytest --ignore=tests/api --ignore=tests/test_review_admins_unit.py -q(156 passed, 2 skipped)connected, lifecycle settled athealthywith no active lease, and no node-409 entries recurred after deploymentProduction observation
About 23 minutes after the successful canary, the remote node VPS itself became unreachable on SSH and both node ports from the panel and an independent network path. The panel and the other nodes remained healthy, and the fixed lifecycle 409 did not recur. The later
Request timed outstate is therefore tracked as a separate infrastructure outage rather than evidence of the cross-worker race returning.Test-suite note
The repository contribution guide names
next, but that branch is not present on the upstream remote, so this PR targetsdev. The full API suite is currently blocked by its local test database/auth seeding setup; the affected node lifecycle unit and integration-adjacent tests pass.Summary by CodeRabbit
Bug Fixes
Tests