Skip to content

fix(node): verify broken backend health before reattaching - #1009

Merged
T3ST3ST3R0N merged 1 commit into
PasarGuard:devfrom
dr-hoseyn:codex/fix-node-backend-health
Oct 12, 2026
Merged

T3ST3ST3R0N merged 1 commit into
PasarGuard:devfrom
dr-hoseyn:codex/fix-node-backend-health

Conversation

@dr-hoseyn

@dr-hoseyn dr-hoseyn commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Summary

When a WireGuard interface disappears, the node can still report started=true while backend stats fail. Recovery previously trusted that flag and marked the attachment healthy without recreating the interface.

Check backend stats before reattaching when either the local health or the lifecycle observation is broken. A failed probe keeps the attachment from claiming success and lets the existing recovery path send Start. Recovered backends still attach without restarting, and healthy sibling attachments keep their existing behavior.

Refs #1007. Addresses the confirmed WireGuard recovery failure; the separately reported Xray inbound failure has not been reproduced.

Type of change

  • Bug fix

Checklist

  • I tested the change locally.
  • I added or updated tests for behavior changes. Regression checks were run locally without including test files in this PR.
  • I did not include secrets, tokens, private keys, or unrelated changes.

Testing

  • python -m pytest tests/test_node_start_timeout.py tests/test_node_reconnect_recovery.py tests/test_node_manager_sync.py tests/test_node_manager.py tests/test_node_sync.py -q --disable-warnings: 42 passed.
  • Eight local regression cases passed: missing-interface recovery with local/shared broken state, failed-probe refusal, recovered-backend attachment, healthy sibling attachment, in-flight Start protection, and explicit restart.
  • ruff check --no-fix app/operation/node.py, ruff format --check app/operation/node.py, and git diff --check passed.

Screenshots

Not applicable.

Notes for reviewers

Only app/operation/node.py changes (7 added lines). No test, documentation, dependency, or schema files are included. Validation used mocked node RPCs; no live Linux node was modified.

Summary by CodeRabbit

  • Bug Fixes
    • Backend statistics are now checked before connecting when the service reports a broken health or lifecycle status, helping ensure its condition is verified before proceeding.

@coderabbitai

coderabbitai Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 299f9a24-f4e5-4e85-9e0b-705bbea0bfee

📥 Commits

Reviewing files that changed from the base of the PR and between 92acbae and c38dd23.


📒 Files selected for processing (1)
  • app/operation/node.py

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



Walkthrough

NodeOperation._attach_if_running now probes backend stats before attaching when backend health or the observed lifecycle status is BROKEN. The existing connection and lifecycle-health update steps continue after the probe completes.

Changes

Node Attachment

Layer / File(s) Summary
Probe before attachment
app/operation/node.py
When backend health or the observed lifecycle status is BROKEN, _attach_if_running calls get_backend_stats() before connecting and updating lifecycle health.

Priority: ➖ Normal

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

Change: Bug fix

Suggested reviewers: m03ed

Merge Risk: ⚪ Minimal · up to c38dd

The change checks backend stats before reattaching a node whose backend looks broken, so a failed probe stops the attachment from being marked healthy and the existing recovery path can run. No concrete merge-blocking defect was found.

Pre-merge checks | Passed 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: verifying broken backend health before reattaching a node.
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files.
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.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

A rabbit checks the backend’s state,
Then waits before the attach can start.
Stats arrive before the connection,
Health updates follow in sequence.
The burrow hums; the node is ready.

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

@dr-hoseyn

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@T3ST3ST3R0N
T3ST3ST3R0N merged commit 7487b4d into PasarGuard:dev Oct 12, 2026
10 checks passed
Free-Guy-IR added a commit to Free-Guy-IR/panel that referenced this pull request Nov 3, 2026
… not reattached while the probe fails

RED on b8e5a6d61: 3 failed, 1 passed (the healthy-backend guard). Upstream 7487b4d (PasarGuard#1009) ships without a test.
Free-Guy-IR pushed a commit to Free-Guy-IR/panel that referenced this pull request Nov 3, 2026
Free-Guy-IR added a commit to Free-Guy-IR/panel that referenced this pull request Nov 3, 2026
…rd#978 and PasarGuard#1085 as ported by their B-NODE cherry-picks and take them off the port queue
Free-Guy-IR added a commit to Free-Guy-IR/panel that referenced this pull request Nov 3, 2026
…d#1009 attach path reads, and pin concurrent reconnects of a broken backend to the probe result

The cherry-pick of upstream PasarGuard#1009 (e612185) makes _attach_if_running read
pg_node.get_health() before connecting. The real bridge node always has it;
the HealthyNode double in test_node_multicore did not, so the AttributeError
was swallowed by the attach path's except and the test saw a Start instead of
an attach. The assertion is unchanged; the double now answers HEALTHY, records
that health was read before connect, and has no get_backend_stats, so a
healthy node that got probed would still fail the test.
Free-Guy-IR added a commit to Free-Guy-IR/panel that referenced this pull request Nov 3, 2026
…multicore healthy-node test double, not the code
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.

2 participants