Repository navigation
fix(orchestrator): make NNS Recovery on Failover Nodes retry-safe - #11768
Merged
pierugo-dfinity merged 9 commits intoOct 7, 2026
Merged
pierugo-dfinity merged 9 commits into
pierugo-dfinity merged 9 commits into
Conversation
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
CUP persistence still precedes an interruptible registry-store replacement, which can recreate the stuck recovery state.
Review effort: Balanced
Findings: 1
Open (3)
What changed in this PR
Makes NNS failover recovery retry-safe by delaying recovery CUP persistence until registry download succeeds.
Changes:
- Checks for NNS recovery before selecting and persisting the latest CUP.
- Persists the recovery CUP after downloading registry data.
- Strengthens the failover system-test scenario and enables restored-node log collection.
| File | Description |
|---|---|
rs/orchestrator/src/upgrade.rs |
Reorders registry recovery and CUP persistence. |
rs/orchestrator/src/catch_up_package_provider.rs |
Exposes CUP persistence within the crate. |
rs/tests/consensus/subnet_recovery/sr_nns_failover_nodes_test.rs |
Adds realistic registry-version divergence. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
✅ No security or compliance issues detected. Reviewed everything up to 71cd2a0. Security Overview
Detected Code Changes
|
AleDema
pushed a commit
to AleDema/ic
that referenced
this pull request
Oct 6, 2026
Hello, me again :D We need to disable mainnet NNS recovery *again*, this time because it actually found a real (small) bug in the orchestrator. dfinity#11768 patches it, meaning we need to wait until it lands in mainnet before being able to reenable the test. On top of that - Remove `--config=flaky_retry` since the test itself takes 2 hours so let's try it only once. - Bump `timeout-minutes` by a bit to make Bazel handle the timeout (see its own `--test_timeout`) and exit more "cleanly".
eichhorl
approved these changes
Oct 7, 2026
pierugo-dfinity
enabled auto-merge
October 7, 2026 13:58
pierugo-dfinity
deleted the
pierugo/upgrade-loop/failover-nns-recovery-retry-safe
branch
October 7, 2026 14:51
AleDema
pushed a commit
to AleDema/ic
that referenced
this pull request
Oct 11, 2026
…es_test_local (dfinity#11795) ## Problem `//rs/tests/consensus/subnet_recovery:sr_nns_failover_nodes_test_local` flaked twice in the week up to 2026-10-08 (2 of 78 runs, both on master). Both times it failed the same way in the `ProposeCUP` step: all three of `ic-admin`'s connection attempts to the parent NNS node's `:8080` timed out (`Failed to connect to [...]:8080: Elapsed(())`, then `None of the provided NNS urls are reachable`). In the passing retries the step took 2-4 s. ## Root cause The Local backend creates each group's bridge with `ip link add name {bridge} type bridge`, without specifying a MAC address. It creates each VM's TAP with `ip tuntap add`, which gives the TAP a random MAC. A Linux bridge whose MAC was not set explicitly takes the lowest MAC among its ports, and recomputes it whenever a port is added or removed (`br_stp_recalculate_bridge_id`). The bridge's MAC is the MAC of the gateway `<prefix>1`, through which GuestOS reaches the driver's addresses. Right before `ProposeCUP`, the test starts the `httpbin` universal VM that serves the registry tarball. Its TAP is the 10th on the bridge, so in about 1 of 10 runs it has the lowest MAC and the gateway's MAC changes under the running guests: - Their neighbour-cache entries for the gateway keep the old MAC, which still belongs to another TAP. - So the bridge passes their frames up as `PACKET_OTHERHOST`, and IPv6 input drops them. The one exception is the guest behind the TAP that owns the old MAC, whose frames still match. - A guest only recovers once its own entry for the gateway expires and is re-resolved. The entry stays REACHABLE for a random 15-45 s, then goes STALE. The next packets go through 5 s of DELAY and 3 unicast probes before a multicast solicitation finds the new MAC. The host's neighbour solicitations come from the bridge's link-local address, so they don't refresh the entry for `<prefix>1`. - New connections therefore get through again about 23-53 s after the flip. Long-lived TCP streams resume only at their next retransmission, after about 53 s or about 107 s. `ic-admin` gives up 40 s after its first connection attempt. So the test fails when the parent NNS node is cut off and its random reachable time is long. Both failed attempts show this fingerprint. The driver streams the journald of the restored IC's 5 nodes. In each failure, within about 0.3 s of the httpbin TAP being attached, 4 of those 5 streams stopped. Five of these eight streams resumed together, 52.6-52.9 s after the attach. The other three were still silent when the test ended, including the second failure's parent NNS node. Meanwhile the serial consoles, the driver and VM-to-VM traffic carried on. The backlog that the first failure's parent NNS node delivered once its stream resumed shows its replica finalizing blocks throughout the gap. The passing retries show no stall. The MAC flip is as old as the Local backend; what changed is how long the outage lasts. - We have logs for 162 passing attempts of this test and its `_head_nns` variant from before dfinity#11768. In 21 of them (13%), `ProposeCUP` took 11-40 s instead of 2-4 s. - These durations mostly match `ic-admin` connecting on a later try: it tries at 0, 15 and 30 s, for up to 10 s each. Seven attempts got through only on the third and last try, and two of those (39 s and 40 s) only seconds before it would have given up. - In those 21 attempts, the parent NNS node's last traffic with the driver before the flip was the `DownloadParentNNSStore` rsync. It had ended 15-37 s earlier, so the parent's gateway entry had less REACHABLE time left when the MAC changed. dfinity#11768 dropped the name of the restored IC, so the driver now streams its nodes' journald. That stream keeps the parent's gateway entry fresh until the very moment of the flip. Of the 40 attempts that ran with this change, 4 show the fingerprint of a MAC flip. In 3 of those the parent NNS node was cut off, and 2 of the 3 failed. dfinity#11778, merged 8 minutes before dfinity#11768, also added guest traffic to `<prefix>1` by serving NTS there, and CI can't tell the two changes apart. ## Fix Give the bridge a fixed, deterministic MAC at creation (`ip link add name {bridge} address {mac} type bridge`). This sets `addr_assign_type` to `NET_ADDR_SET`, after which the kernel never recomputes the MAC. The MAC is `6a:ff:` followed by the first 4 bytes of the digest that also names the bridge. It can't equal a VM's MAC. VM MACs have a `NodeType` index as their second byte, both in the backend (`vm_mac`: `6a:01:…`) and in IC-OS (`calculate_deterministic_mac`: `6a:<index>:…` or `7a:<index>:…`), and 0xff is not a `NodeType` index. This also covers VM restarts and reboots: `start_vm` deletes and recreates the VM's TAP, so a restart could move the gateway MAC too. ## Verification - **Kernel source and namespace reproductions.** I checked the kernel source (v6.8 and master) and reproduced the bug in unprivileged network namespaces on the devenv's kernel 6.8. - The largest reproduction used a bridge set up like `create_group`, with 9 veth "guests" streaming TCP to an off-link address on `lo`. - In 4 of 4 runs, attaching a TAP with the lowest MAC cut 8 of the 9 guests off from the host, for about 53 s or about 107 s. VM-to-VM traffic was unaffected. - With a fixed bridge MAC, the MAC never changed and no guest lost connectivity. - **A/B runs of the real test on the devenv.** These used throwaway instrumentation, not part of this PR. It gives the httpbin TAP a MAC lower than any random TAP MAC (`02:00:00:00:00:01`) and logs the bridge's MAC around every TAP attach. - **Without the fix**, attaching httpbin's TAP moved the bridge MAC in 2 of 2 runs (e.g. `0e:3d:07:9f:24:f2` → `02:00:00:00:00:01`). In both runs the journald streams of 4 of the 5 streamed VMs stopped for 53-55 s. The one survivor was each time the VM whose TAP held the old bridge MAC. - In the first run, the parent NNS node was among the stalled VMs, and `ProposeCUP` took 32 s because 2 of `ic-admin`'s 3 tries failed. - In the second run, the parent NNS node was the survivor, and `ProposeCUP` took 3.6 s. - **With the fix**, the bridge kept its `6a:ff:…` MAC through every TAP attach, including httpbin's `02:00:00:00:00:01`, in 2 of 2 runs. No journald stream stalled (largest gap 5.5 s), and `ProposeCUP` took 3.6 s and 2.1 s. - The runs were sequential. On the 64-core devenv, 3 concurrent runs of this test (27 VMs with 6 vCPUs each) slowed the VMs so much that the NNS canister installation timed out (300 s) in setup. - **This PR as is.** `bazel test --runs_per_test=3 --local_test_jobs=1 //rs/tests/consensus/subnet_recovery:sr_nns_failover_nodes_test_local` passed 3 of 3, with `ProposeCUP` taking 2.1-4.8 s. - `//rs/tests/driver:unit_tests` and `//rs/tests/idx:test_e2e_scenarios` pass, and `ci/scripts/rust-lint.sh` is clean. This PR was created following the steps in `.claude/skills/fix-flaky-tests/SKILL.md`. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
maksym-arutyunyan
pushed a commit
to maksym-arutyunyan/ic
that referenced
this pull request
Oct 20, 2026
dfinity#11699 reached mainnet NNS (proposal [144319](https://dashboard.internetcomputer.org/proposal/144319)) so we can use mainnet's `ic-recovery` again. dfinity#11768 reached mainnet NNS (proposal [144480](https://dashboard.internetcomputer.org/proposal/144480)) so we can reenable the test again. Tested locally.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



During an NNS Recovery on Failover Nodes, the failover nodes' orchestrators detect it by consistently looking for a
cup_contents.registry_store_uriin their subnet'sCatchUpPackageContentsat the latest registry version and download a recovery local store before restarting the orchestrator process. If the download fails, the upgrade loop retries at the next iteration.Problem
Since the recovery CUP was persisted before attempting the download, the next iteration of the loop now tries to determine its
subnet_idout of the recovery CUP, but the latter's registry version corresponds to the new registry, that we haven't extracted yet. The upgrade loop is then stuck insidefn get_subnet_idbecause it doesn't have the CUP's registry version available.This download almost always fails the first time in
sr_nns_failover_nodes_testbecause the UVM isn't fully ready yet by the time the nodes attempt to download.Then why did it not flake before?
The system test setup is not 100% realistic as the original registry has 1 version and the parent NNS registry has 2 versions. The recovery CUP has registry version 2, which by chance (or non-chance), is still valid even when adding the parent NNS mutations on top of the original registry. By modifying the system test and adding a few dummy versions to the original registry (see changes), which is much more realistic, the test starts failing.
Then why did it not appear in the mainnet NNS setup?
The mainnet NNS setup also uses NNS recovery on failover nodes, and with an original registry with many more versions than the parent NNS, so why does it work there?
We were lucky: in this setup, the UVM is already setup before attempting this whole process, so the download never fails and we never stay stuck in a loop.
Why did it appear only now?
#11238 recently made the upgrade loop read the
subnet_idbetween the CUP is persisted but before attempting to download the local store. This is the exact samefn get_subnet_idthat returns an error in the scenario described above.Proposed solution
Make a failed download retry-safe. To do so, we propose to not persist a CUP when it actually corresponds "to a different registry". This means we should look for the
registry_store_uribefore determining the latest CUP (which persists it). Though this is not sufficient: when restarting the orchestrator process, we want to have persisted the recovery CUP (such that the new process sees it). Thus, persist it precisely just before restarting the process. If the download failed, the CUP wouldn't get persisted and we retry the download in the next iteration.P.S.: also stop leaking tempdirs if anything fails
P.S. 2: also remove the name on the restored IC to collect IC node logs of the latter (see how
sync_with_vectoronly reads the unnamed IC)