Skip to content

feat(system-tests): boot nested VMs on the local backend - #11265

Merged
basvandijk merged 16 commits into
masterfrom
bas/local-backend-nested
Aug 26, 2026
Merged

basvandijk merged 16 commits into
masterfrom
bas/local-backend-nested

Conversation

@basvandijk

@basvandijk basvandijk commented Aug 21, 2026 •

Copy link
Copy Markdown
Collaborator

Stacked on #11270, which gives the local backend's ic-gateway a resolvable domain and a certificate that nodes trust. Review that one first.

Problem

Nested system-tests (rs/tests/nested) drive the whole node deployment chain: SetupOS installs HostOS onto a blank disk, HostOS boots a nested GuestOS VM, and that GuestOS registers with the NNS. All five non-bare-metal targets were pinned to Farm because setup_and_start_nested_vms was not supported on the local backend.

What was missing

Three things in the driver:

  • the install target was built as a DiskImage::Url whose _URL variable run_systest.sh never sets under the local backend;
  • setup_and_start_nested_vms needed its Local arm;
  • NESTED_CONFIG_IMAGE_PATH claimed .zst for a file nothing compresses, which the local backend would have run unzstd over.

The fourth — the nested node's NNS URL — is what #11270 is for. A node that is not in the registry yet cannot pass the replicas' firewall, so it registers through the ic-gateway; that needed the gateway to be reachable by name and trusted, which it now is on both backends. nested_nns_url is consequently backend-agnostic.

Also: pad_to_request_alignment now refuses a GPT image rather than silently displacing its backup header, and the nested VM drops from 32 GiB to 16 GiB — the floor, since the driver takes 8 GiB off and HostOS then takes 4 more, leaving the GuestOS the same 4 GiB every other node VM gets. That reduction applies on Farm too; all 20 Farm nested targets pass with it.

The blocker: SetupOS halts because chrony can never synchronise

check-ntp.sh is the one SetupOS check not gated on ic.setupos.run_checks, so setupos-disable-checks does not skip it. It waits 60s for NTPSynchronized and then halts the installation forever — log_and_halt_installation_on_error ends in sleep infinity.

Serving NTP to the group ourselves does not fix it, and the first two commits here do exactly that before it is reverted. chrony's authselectmode defaults to mix, and sources.c then marks the authenticated sources required as soon as both authenticated and unauthenticated sources are configured — precisely what chrony.conf does in pairing fourteen nts servers with two plain pools. Sources configured from names that never resolve still count. So the clock can only ever be synchronised from one of those fourteen NTS servers; the driver's SNTP server was polled every 64s for a whole run and never selected, with chronyd saying so in the node journals:

Can't synchronise: no required source in selectable sources

Reproduced against chronyd 4.8 directly: given that config shape it polls a reachable plain server for 100s without selecting it, and selects it in 4s once authselectmode ignore is added. Satisfying the check for real would mean serving NTS under one of those fourteen hostnames with a certificate the guest trusts, which no test harness can arrange.

So the check is gated instead, like the four that also need connectivity, and the reasoning is recorded on check_ntp. Nothing is lost: every test VM takes its clock from the hypervisor via -rtc base=utc.

Scope

registration and both *_upgrade_smoke_test targets are un-pinned, along with the _head_nns variants system_test_nns generates from them — backend is per target definition. All six were run locally before dropping the pins.

The two *_from_latest_release_to_current targets stay pinned: they install from a prebuilt mainnet SetupOS image, of which setupos-disable-checks can only rewrite the grub boot args, so their check-ntp.sh predates this gate.

One thing for reviewers to weigh: this takes the non-manual nested _local targets from two to six, and system_tests.bzl:342 reserves CPU only — ceil(cpus / cpus_oversubscription_factor) = 9 of the 27 these declare — with no accounting for memory or disk. Three can therefore run concurrently on a 32-core runner, for ~84 GiB of nominal VM memory and ~60 GiB of qcow2 overlays. cpus_oversubscription_factor = 1 would serialise them if that turns out to matter; no target in the repo sets it today, so this is left at the default.

🤖 Generated with Claude Code

@github-actions github-actions Bot added the feat label Aug 21, 2026
@basvandijk
basvandijk requested a balanced review from Copilot August 21, 2026 14:31
@basvandijk basvandijk added the CI_ALL_BAZEL_TARGETS Runs all bazel targets label Aug 21, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Enables nested VM system tests on the local QEMU backend while preserving Farm behavior.

Changes:

  • Adds local SetupOS boot, resource, networking, and NNS registration support.
  • Provides local DNS/SNTP services required by SetupOS.
  • Enables the registration test locally and adds safety around GPT image alignment.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated no comments.

Show a summary per file
File Description
rs/tests/nested/src/util.rs Whitelists local nested-node registration traffic.
rs/tests/nested/src/lib.rs Reduces local nested VM memory allocation.
rs/tests/nested/BUILD.bazel Enables local registration testing and updates TODOs.
rs/tests/driver/src/driver/test_env_api.rs Removes obsolete empty-disk URL helpers.
rs/tests/driver/src/driver/serve_ntp_task.rs Implements and tests the local SNTP server.
rs/tests/driver/src/driver/resource.rs Selects backend-appropriate empty disks.
rs/tests/driver/src/driver/nested.rs Corrects the raw config-image extension.
rs/tests/driver/src/driver/mod.rs Exposes the NTP task module.
rs/tests/driver/src/driver/local_backend.rs Adds NTP DNS records and GPT-safe alignment.
rs/tests/driver/src/driver/ic_images.rs Adds backend-aware SetupOS and empty-disk selection.
rs/tests/driver/src/driver/group.rs Runs NTP as a supervised local task.
rs/tests/driver/src/driver/bootstrap.rs Boots nested VMs locally and selects a reachable NNS URL.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread rs/tests/driver/src/driver/bootstrap.rs Resolved
Comment thread rs/tests/nested/src/lib.rs Resolved
Comment thread rs/tests/driver/src/driver/nested.rs Resolved
Comment thread rs/tests/driver/src/driver/resource.rs Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.

Comment thread ic-os/components/setupos/check-ntp.sh Resolved
Comment thread rs/tests/driver/src/driver/bootstrap.rs Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated no new comments.

Suppressed comments (1)

rs/tests/driver/src/driver/bootstrap.rs:586

  • The Local branch panics before reaching the dummy fallback when no IC/NNS was created: TopologySnapshot::root_subnet() calls root_subnet_id(), which explicitly panics if the registry has no root subnet (test_env_api.rs:547-559). This breaks the existing //rs/tests/node:launch_single_host_local setup, which starts only NestedNodes and intentionally creates no IC infrastructure. Guard the topology lookup (for example with env.prep_dir("")) and use the dummy URL when no prep state exists.
        SystemTestBackend::Local => env
            .topology_snapshot()
            .root_subnet()
            .nodes()
            .next()

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated no new comments.

@basvandijk
basvandijk changed the base branch from master to bas/local-backend-gateway-cert August 22, 2026 22:48
@basvandijk
basvandijk force-pushed the bas/local-backend-nested branch from 2476795 to 688f7e0 Compare August 23, 2026 00:12
@basvandijk
basvandijk requested a balanced review from Copilot August 23, 2026 00:12

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 12 out of 12 changed files in this pull request and generated no new comments.

@github-actions github-actions Bot added the @sdk label Aug 26, 2026
The function had become functionally identical to the code it replaced
(modulo extra logging), so restore the original inline block to keep the
diff small, as requested in review.

Co-Authored-By: Claude Fable 5 <[email protected]>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated no new comments.

The `let mut ic` split only existed so the Local backend could insert
`with_group_wide_firewall_whitelist()` before starting; that conditional
went away when nested nodes started registering through the ic-gateway,
so put the original method chain back. The file now matches master.

Co-Authored-By: Claude Fable 5 <[email protected]>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated no new comments.

Comment thread ic-os/components/setupos/check-ntp.sh Resolved
Comment thread rs/ic_os/config/types/src/lib.rs Resolved
Comment thread rs/tests/driver/src/driver/bootstrap.rs Resolved
Comment thread rs/tests/driver/src/driver/ic_images.rs Resolved
Comment thread rs/tests/driver/src/driver/resource.rs Resolved
Comment thread rs/tests/driver/src/driver/resource.rs Resolved
Comment thread rs/tests/nested/BUILD.bazel Resolved
Comment thread rs/tests/nested/BUILD.bazel Resolved
Trim or delete the comments review flagged as bloat, rewrite the two
nested BUILD.bazel TODOs to say plainly why the prebuilt-mainnet-image
targets stay pinned to Farm, and read the GPT signature with
read_exact_at instead of seek + read_exact.

Co-Authored-By: Claude Fable 5 <[email protected]>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated no new comments.

@basvandijk
basvandijk requested a review from frankdavid August 26, 2026 14:08
pull Bot pushed a commit to bit-cook/ic that referenced this pull request Aug 26, 2026
…name (dfinity#11270)

## Problem

On the local backend the ic-gateway served a **self-signed** certificate
for **`<vm name>.local`**. Neither half is usable from inside the group,
so every client papered over both — a `reqwest` resolve override plus
`danger_accept_invalid_certs`.

That works for driver-side clients and for nothing else. A *node* has no
such knobs, which is why a nested node on this backend registers
straight against a replica's `:8080` instead of going through the
gateway as it does on Farm — and why it needs
`with_group_wide_firewall_whitelist()` to get there.

Both halves turn out to be fixable without touching any node.

## The domain

`<vm name>.ic.net`, registered with the group's `dnsmasq` through
`add_dns_record` — the same mechanism `setup_api_bn_local_playnet`
already uses for `apibn-{idx}.ic.net`. The suffix becomes one shared
constant.

It could not have stayed under `.local`: GuestOS and HostOS resolve
through systemd-resolved, which routes `*.local` to mDNS and never to
the unicast `DNS=` servers `dnsmasq` answers on. No amount of dnsmasq
configuration would make such a name resolve in a guest.

Only the apex is registered — a hosts file has no wildcards, and nothing
inside a VM resolves a canister subdomain today. A wildcard would mean
`--address=/<domain>/<addr>` on dnsmasq's command line, which `SIGHUP`
does not re-read.

## The certificate

Issued by the **dev root CA** instead of self-signed. That CA is already
in every *dev* IC-OS image's trust store —
`ic-os/{guestos,hostos}/context/Dockerfile` installs
`canister_http_test_ca.cert` and runs `update-ca-certificates`, in the
`output_dev` stage only — and its private key is checked in beside it.
This is how `canister_http` and `ckbtc` already serve HTTPS that nodes
accept, and the `dev-certs/README.md` documents exactly this use.

So a node reaches the gateway with no node side configuration: no
config-image plumbing, no `CONFIG_VERSION` bump, no production code
change. Production images are unaffected — the CA lives in the
`output_dev` stage.

This deliberately does **not** extend to the API boundary nodes, whose
ephemeral CA stays as it is. `nns_delegation_manager` builds its root
store from the compiled-in `webpki_roots` and never consults
`/etc/ssl/certs`, which is precisely why
`extra_api_boundary_node_trust_anchors_pem` exists; the client that
reaches the *gateway* is a different one (the orchestrator's `ic-agent`,
which goes through `rustls-platform-verifier` → the OS store).

## Driver side

`uses_self_signed_cert` gives way to `root_certificate()`. `reqwest`
*adds* an extra root to the platform's own rather than replacing them,
so clients now verify the chain instead of skipping verification.

`resolve_override_for_url` stays: the driver sits in the group's network
namespace but reads the host's `/etc/resolv.conf`, whose nameserver is
unreachable from there, so driver-side DNS is dead regardless of what
`dnsmasq` knows. Fixing that means giving the driver a mount namespace,
which is left for its own change.

Two mechanical additions: `x509-parser` in `rcgen`'s features, for
`CertificateParams::from_ca_cert_pem`; and `rsa`, to re-encode the
checked-in PKCS#1 CA key as the PKCS#8 that `rcgen`'s `ring` backend
requires.

## Verification

`dfx_smoke_test_local` and `nns_dapp_test_local` both pass, fetching
canister assets over `https://<canister id>.ic-gateway.ic.net` with the
chain verified rather than accepted blindly. `dfx_smoke_test` and
`nns_dapp_test` still pass on Farm.

dfinity#11265 will be restacked on top of this, dropping its plain-HTTP nested
path and the group-wide firewall whitelist that goes with it.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
@basvandijk basvandijk removed the CI_ALL_BAZEL_TARGETS Runs all bazel targets label Aug 26, 2026
@basvandijk
basvandijk added this pull request to the merge queue Aug 26, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to no response for status checks Aug 26, 2026
@basvandijk
basvandijk added this pull request to the merge queue Aug 26, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to no response for status checks Aug 26, 2026
@basvandijk
basvandijk added this pull request to the merge queue Aug 26, 2026
Merged via the queue into master with commit e9fd136 Aug 26, 2026
45 checks passed
@basvandijk
basvandijk deleted the bas/local-backend-nested branch August 26, 2026 22:21
AleDema pushed a commit to AleDema/ic that referenced this pull request Oct 11, 2026
The local system-test backend now runs an NTS time server for each test
group, so the VMs of `_local` system tests synchronize their clocks to
the host, as Farm VMs do with the public time servers.

# Why

The VMs seed their clocks from QEMU's emulated RTC, which only has
whole-second resolution, and their chrony can't reach any time server
from the backend's network namespace. So nodes stay up to ~2s apart for
the whole test. A node whose clock runs ahead has its block proposals
deferred by its peers, which made `query_stats_above_threshold_local`
flake (dfinity#11771).

A plain NTP server is not enough. IC-OS's `chrony.conf` pairs 14 NTS
servers with two plain pools. Under chrony's default `authselectmode
mix`, the NTS sources then get the `require` option, so chrony only
adjusts the clock while an NTS source is selectable. Names that never
resolve count too. dfinity#11265 tried a plain server and reverted it for this
reason ("Can't synchronise: no required source in selectable sources").

# How

- `create_group` starts ntpd-rs, bound to the group's gateway address.
It answers NTS key exchanges (tcp/4460) and NTP (udp/123) and serves the
host's clock as stratum 1 (`local-stratum = 1`). It has no sources of
its own, so it never adjusts the host clock.
- It presents a certificate for `time.cloudflare.com`, the first NTS
server in `chrony.conf`. The certificate is issued from the dev root CA,
which dev GuestOS and HostOS images trust and which the backend already
uses for the IC gateway's certificate.
- The group's dnsmasq resolves `time.cloudflare.com` to the gateway (and
answers its A query with an empty NOERROR).
- `delete_group` stops the server and logs its log, which names every VM
that completed a key exchange. That is the only record for VMs whose
journals are not streamed, such as API boundary nodes and nested HostOS.
- ntpd-rs comes from its 1.9.0 release `.deb` (amd64, so the target is
x86_64-only), extracted like the OVMF firmware.

# Limitations

- **First sync takes ~30s after chronyd starts.** chronyd's first DNS
lookup happens before GuestOS networking is up, and chrony only retries
28s later. Offsets under 1s are then slewed, which takes up to 12s more.
A test whose setup is fast can therefore start before the clocks are in
sync. This is why we still need dfinity#11771:
`query_stats_above_threshold_local` can run its first queries before its
nodes are in sync, so it keeps the larger `unit_delay` that tolerates
the skew.
- **Production images aren't covered.** Production IC-OS images don't
trust the dev CA, so nodes booted from them stay unsynchronized as
before. That includes the mainnet versions some upgrade and
compatibility tests start from. SetupOS doesn't trust the dev CA either,
but its NTP check is already skipped in test images.

# Verification

- chronyd 4.8 (the GuestOS version) with IC-OS's unmodified
`chrony.conf` against this ntpd-rs configuration, in a private network
namespace: the source was NTS-authenticated and selected 8s after start.
- `//rs/tests/query_stats:query_stats_above_threshold_local`, run twice:
all 5 nodes logged `Selected source <gateway> (time.cloudflare.com)`. At
the end of the test, chrony reported a ~2µs offset on every node.
- `//rs/tests/nested:registration_local`: the system node, the API
boundary node and the nested HostOS completed NTS key exchanges. SetupOS
failed the TLS handshake, as expected.

# Side finding

The same `authselectmode mix` rule applies in production: the "INSECURE
POOL (FALLBACK)" in `chrony.conf` never acts as a fallback, because
chrony won't adjust the clock from the pools while no NTS source is
selectable.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants