Repository navigation
fix(core): restart affected nodes after core deletion - #934
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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 |
|
Thanks, merged. Capturing the affected nodes before the delete was exactly what was missing, and clearing |
… to ff6e596 Every Port queue line in the panel and side-repository ledgers now says `security: yes` or `security: no`. Security: c9b445a (passkey client rename), eb50bfd, PasarGuard#938, PasarGuard#940, PasarGuard#942, the cryptography 50.0.2 security release, and the ten commits of upstream's PasarGuard#979 permission-leak batch (user list scopes, API-key permissions, HWID visibility, users.read, the Telegram inline search), which no branch ports yet. Checked with git ls-remote on 2026-10-09: upstream dev moved to ff6e596. The PasarGuard#979 batch, the node RPC fixes (PasarGuard#977, PasarGuard#978), the core-deletion restart (PasarGuard#934), dashboard fixes (PasarGuard#852, PasarGuard#907, PasarGuard#949, PasarGuard#952), performance changes (PasarGuard#945, PasarGuard#853, PasarGuard#855) and the merged dependabot bumps (ruff, uvloop, fastapi) join the queue; the ruff and uvloop conditional waivers ended when upstream merged them. Waived: PasarGuard#980 and its branch commit (the Telegram notifier workflow the fork deleted) and the superseded fastapi dependabot head b021d6f. The refs snapshot records the five new heads. Fork core-kit main 90701408 now contains upstream d2ecb5bd, so that ledger is empty. No side repository gained an upstream commit since 2026-10-07.
…ain bba95f274 Checked with git ls-remote on 2026-10-11 02:55 UTC. Panel dev moved from d94e157 to 83fe90e with 22 commits; main is still v5.4.1. - PasarGuard#879 (2d0ca81, loopback Xray client inbounds) is ported by design: the fork took the open pull request on 2026-09-25 as 2e7fc45 with migration bfd88026565b, the same listener rewrite. - PasarGuard#934 (a5b28f3) moves from the port queue to a dated waiver until 2026-11-09: the fork refuses to delete a core that nodes still use (W3-013, fix/node-health) instead of restarting those nodes. - PasarGuard#993 (Hysteria2 FinalMask without a udp mask) is queued until 2026-10-18: the fork has the same FinalMask | dict field and the same non-null-safe udpHop reads, so a udpHop-only host can fail the whole subscription. - PasarGuard#984, PasarGuard#985, PasarGuard#986, PasarGuard#989, PasarGuard#944, PasarGuard#864, PasarGuard#948, PasarGuard#951, PasarGuard#778, PasarGuard#774, PasarGuard#787, PasarGuard#994, PasarGuard#865, PasarGuard#875, PasarGuard#718, PasarGuard#967, PasarGuard#772, PasarGuard#662, PasarGuard#995 and PasarGuard#913 are queued as security: no until 2026-10-25, each with its reason; PasarGuard#913's node-removal half is already in the fork through sync_remove_users. - The branch commits that upstream squash-merged (the three dashboard branches, telegram/tests, fix/core-editor-api-section-followup, fix/hwid-count-test-cleanup, fix/hysteria-finalmask-quic-only) follow their squash, by patch-id or by an equal tree. Scripts main moved to bba95f274 (PasarGuard#35, PasarGuard#36, PasarGuard#37 after PasarGuard#34). The three squashes are queued security: no until 2026-10-25, and their pre-squash branch commits are waived as superseded (equal trees). Against live upstream the panel gate now fails only on the 17 port-queue commits classified security: yes, and the forks gate only on node f72ac0ef (security: yes). No upstream commit is undecided.
…position, port status, 2026-10-29 upstream - PasarGuard#934 a5b28f3 is released in v5.5.0 and v5.5.1, not dev-only: by main's ruling of 2026-10-29 it moves from Waived to the Port queue, owed by PANEL-NODEHEALTH's standalone increment "PasarGuard#934 + W3-013 (B2)", on main by 2026-11-09. - certifi 2026.10.23 (PasarGuard#1117, held): the fork answers it with CERTIFI-FIX's certifi steps 3 to 6, image only (all four emSign roots stripped from certifi.where() and pip's bundle, build fails if one remains; source installs uncovered), as PG-MERGE recorded. - e538dc1 and 80d855f name where their fork fixes stand: PG-C2-PORT's address cap on fix/port-1053-format-fields and RI-FIX's removal interleaving test 580af7c, both not on main yet. - nats-py PasarGuard#920 c15150b is ported, so its queue line goes. - Held: upstream dev of 2026-10-29, PasarGuard#1122 b1fd634 (pytest-asyncio 1.4.1, dev group) and PasarGuard#1123 de75b25 (sse-starlette 3.6.0), and the dependabot head 3de496c with the same patch; .upstream-refs records dev de75b25 and that branch head. Gate at HEAD with --today 2026-10-29: OK, not at parity, 182 owed.
…and 2026-11-09 The seven security ports and the bridge waiver held under 2026-10-28-main-reclassified until 2026-11-08 move to the new decision 2026-11-03-main-spec005-lanes until 2026-11-20: PG-SYNC-551, PG-C2-PORT and PUSH-GATE no longer run, and each entry now names the spec 005 batch and branch that owes it. The PasarGuard#934 entry moves from the standalone PANEL-NODEHEALTH increment to batch B-NODE with the same date. The npm kit waiver moves to batch B-DASH, which owns the core-kit 0.2.12 and xray-config-kit 0.4.1 bumps. The masque merge fa5dfc2 becomes SUPERSEDED-BY-SQUASH like its branch's two commits: upstream deleted the masque branch, the merge is on no upstream line, and the one line its resolution adds is verbatim in 0097556 (PasarGuard#1025, v5.5.0 and v5.5.1).
Port of upstream a5b28f3 (PasarGuard#934, in v5.5.0 and v5.5.1). remove_core_config clears core_config_id on every node of the deleted core, and both DELETE /api/core/{id} and the bulk delete restart those nodes with a forced Start through connect_nodes_bulk instead of the old restart call. Before this, a node whose primary core was deleted kept running the deleted core. Two conflicts are resolved. app/db/crud/core.py keeps upstream's null UPDATE next to the fork's sweep of the additional-core links. app/routers/core.py takes upstream's delete_core_config body, so the file is byte-identical to upstream's. The fork test in tests/api/test_core.py fakes connect_nodes_bulk, which now receives force_start, on the router's node_operator as upstream's tests do (their monkeypatch leaves that instance attribute behind, which hides a patch on the class), and asserts that the restart is forced. tests/api/test_core_delete_restarts_its_nodes.py checks that no active node is left on a deleted primary core after a single or bulk delete, that a core no node uses deletes and restarts nothing, and that a non-forced connect leaves a healthy node on its running config, which is why the restart must be forced. On its own this commit moves every node of a deleted core to the Default Core. The next commit refuses the delete of a core a node still uses (W3-013), and the two ship together. Upstream: a5b28f3 (cherry picked from commit d1e424b179497a9d2efd63c7fb4b50f1541c55ca)
… write that loses its core answers 404 instead of crashing PANEL-W3-013, on top of upstream PasarGuard#934. Deleting a core nulled nodes.core_config_id (the explicit UPDATE PasarGuard#934 adds, the ON DELETE SET NULL key) and swept the additional-core links, so a node silently fell back to core 1 "Default Core Config" and its inbounds, :80 and :443 included, on its next restart (node 37 on 2026-09-18, node 71 on 2026-10-01). With PasarGuard#934 that fallback happens on every dashboard delete of a core in use, and a deleted additional core keeps running on its nodes. delete_core and bulk_remove_cores now call the fork's cores_in_use_message first. It holds the core rows (SELECT ... FOR UPDATE, a no-op UPDATE on SQLite so the delete owns the write lock from the check to the commit), reads every node that uses a selected core as its primary or additional core through read_committed_rows (a REPEATABLE READ session would miss a reference committed after its snapshot), and answers 409 with a string detail naming each core and node; a bulk request is refused as a whole and nothing is changed. An unused core deletes as before, so PasarGuard#934's null and restart path only ever sees a core no node uses. A node edit racing the delete either commits first and blocks it, or fails its foreign-key check once the core is gone. resolve_additional_cores silently dropped a core deleted between validation and write (the edit answered 200 with no link), and create_node/modify_node formatted their 409 from a node object the failed flush had expired, which raised PendingRollbackError (a 500) on every duplicate-name rename too. resolve_additional_cores now raises CoreConfigMissing, and _refuse_node_write rolls back and answers 404 "Core config not found" when a requested core is gone, else 409 with a name captured before the flush. The three core-delete tests PasarGuard#934 added or rewrote in tests/api/test_bulk_delete_entities.py and the fork test in tests/api/test_core.py asserted the Default Core fallback; they now assert the 409 refusal, that no node is restarted, and that the delete succeeds once the nodes are gone. OVERRIDES.md records PasarGuard#934 as ported with this guard on top. (cherry picked from commit 6cab4ba589d930ab7f4f64fe647d3c7349003bc2)
A core delete (DELETE /api/core/{id} and POST /api/cores/bulk/delete) must
answer 409 while any node, in any status, uses the core as its primary or
additional core, name those nodes and cores, and change nothing; a bulk
delete with one referenced core deletes none of them. Cores no node uses
still delete, and a node already left without a core neither blocks nor
changes. A node rename to a taken name must be a 409, not a
PendingRollbackError.
The file also carries the interleaving harness (a session that parks each
statement by its read or write shape under seeded and targeted schedules);
the race tests that use it follow in the next commit.
These tests fail on the PasarGuard#934 port alone and pass with the previous commit.
The suite is 48f69f6b2 from the node-health package, split in two commits.
(cherry picked from commit 1f9fc86299cf1f8644c5d6ac9683f2877eff5496)
…the node or leaves it on the deleted core The interleaving tests race a core delete, single and bulk, against a node edit that moves the node onto the core, an edit that adds the core as an additional core, and a node created on the core, under every seeded and targeted schedule. In every order the node never ends on NULL or on a deleted core, a successful edit stores what it reported, no racing request fails with an unhandled exception, a refused delete answers 409 and keeps the core, and a node that did reach a core the delete then removed gets a forced restart. A node write that loses its core to the delete answers 404 "Core config not found", not a conflict on the node's name. tests/api/test_core_delete_races.py also checks that a deleted additional core is never left running on a node, that restart_nodes=false never leaves an active node on the deleted core, and that a disabled or limited node is never moved onto the Default Core; it reuses the harness of tests/api/test_core_delete_keeps_nodes.py and the helpers of tests/api/test_core_delete_restarts_its_nodes.py. On the PasarGuard#934 port alone 71 of these fail (crashes with PendingRollbackError, nodes left on the deleted core, extras dropped silently); all pass with the W3-013 commit. (cherry picked from commit aec400789ed5825ff3a06452da5e60b817d333b0)
… restarted only onto its new core The router reads the deleted core's nodes before the in-use guard takes the core row lock, as upstream PasarGuard#934 does, so a node that moves off the core in that window passes the guard and still gets the router's forced restart. modify_node already force-starts the moved node, so that restart is redundant, and the router file stays byte-identical to upstream. The race test now records the core each forced restart loads and asserts it is the node's new core, never the deleted one.
Summary
ON DELETE SET NULLdoes not run.Verification
pytest tests/api/test_core.py tests/api/test_bulk_delete_entities.py -q— 32 passed (using the local SQLite test database).ruff check app/db/crud/core.py app/routers/core.py tests/api/test_bulk_delete_entities.py --no-fix— passed.ruff format --check app/db/crud/core.py app/routers/core.py tests/api/test_bulk_delete_entities.py— passed.Bulk deletion now reconnects affected active nodes automatically. Single deletion continues to honor the existing
restart_nodesoption.