From cb840d679dc12a94af98ae03b05f52574facd71d Mon Sep 17 00:00:00 2001 From: Stephan Fitzpatrick Date: Mon, 9 Nov 2026 12:40:05 +0000 Subject: [PATCH] isb 4.1.2: the address check reads only the bridges isb's instances use `GET /1.0/networks?recursion=1` took incusd 12 s on titan (55 networks, each one's state from the host), once a minute, and once timed out. The check now reads each org bridge its instances are on by name (0.2 s each, 11 on titan) and never an egress bridge. Claude-Session: https://claude.ai/code/session_01LJ21XsZE86ywhpFMvYVWmE --- Cargo.lock | 14 +++---- Cargo.toml | 14 +++---- crates/isb-core/src/ipam.rs | 45 +++++++++++++-------- docs/reference/rpc.md | 4 +- sdk/python/pyproject.toml | 2 +- sdk/python/src/isb/__init__.py | 2 +- sdk/python/tests/test_unit.py | 6 +-- sdk/python/uv.lock | 2 +- sdk/typescript/bun.lock | 4 +- sdk/typescript/npm/linux-arm64/package.json | 2 +- sdk/typescript/npm/linux-x64/package.json | 2 +- sdk/typescript/package.json | 6 +-- 12 files changed, 57 insertions(+), 46 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b89bfea..8faa9e1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1329,7 +1329,7 @@ checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695" [[package]] name = "isb" -version = "4.1.1" +version = "4.1.2" dependencies = [ "age", "clap", @@ -1352,7 +1352,7 @@ dependencies = [ [[package]] name = "isb-apps" -version = "4.1.1" +version = "4.1.2" dependencies = [ "age", "base64 0.23.1", @@ -1376,7 +1376,7 @@ dependencies = [ [[package]] name = "isb-core" -version = "4.1.1" +version = "4.1.2" dependencies = [ "age", "base64 0.23.1", @@ -1403,7 +1403,7 @@ dependencies = [ [[package]] name = "isb-daemon" -version = "4.1.1" +version = "4.1.2" dependencies = [ "age", "httparse", @@ -1423,7 +1423,7 @@ dependencies = [ [[package]] name = "isb-egress" -version = "4.1.1" +version = "4.1.2" dependencies = [ "base64 0.23.1", "httparse", @@ -1436,7 +1436,7 @@ dependencies = [ [[package]] name = "isb-server" -version = "4.1.1" +version = "4.1.2" dependencies = [ "argon2", "base64 0.23.1", @@ -1459,7 +1459,7 @@ dependencies = [ [[package]] name = "isb-tui" -version = "4.1.1" +version = "4.1.2" dependencies = [ "isb-core", "libc", diff --git a/Cargo.toml b/Cargo.toml index 3037d44..a1f19db 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -55,7 +55,7 @@ members = ["crates/*"] default-members = [".", "crates/*"] [workspace.package] -version = "4.1.1" +version = "4.1.2" edition = "2024" rust-version = "1.89" license = "LicenseRef-EXA-SL-1.0" @@ -63,12 +63,12 @@ repository = "https://github.com/execution-associates/isb" homepage = "https://github.com/execution-associates/isb" [workspace.dependencies] -isb-core = { path = "crates/isb-core", version = "=4.1.1" } -isb-server = { path = "crates/isb-server", version = "=4.1.1" } -isb-apps = { path = "crates/isb-apps", version = "=4.1.1" } -isb-daemon = { path = "crates/isb-daemon", version = "=4.1.1" } -isb-tui = { path = "crates/isb-tui", version = "=4.1.1" } -isb-egress = { path = "crates/isb-egress", version = "=4.1.1" } +isb-core = { path = "crates/isb-core", version = "=4.1.2" } +isb-server = { path = "crates/isb-server", version = "=4.1.2" } +isb-apps = { path = "crates/isb-apps", version = "=4.1.2" } +isb-daemon = { path = "crates/isb-daemon", version = "=4.1.2" } +isb-tui = { path = "crates/isb-tui", version = "=4.1.2" } +isb-egress = { path = "crates/isb-egress", version = "=4.1.2" } serde = { version = "1", features = ["derive"] } serde_json = "1" diff --git a/crates/isb-core/src/ipam.rs b/crates/isb-core/src/ipam.rs index 74ef5e2..9dec030 100644 --- a/crates/isb-core/src/ipam.rs +++ b/crates/isb-core/src/ipam.rs @@ -635,24 +635,35 @@ pub fn check( only: Option<&str>, report: &mut dyn FnMut(&str), ) -> Result> { - let mut nets: BTreeMap = client - .get("/1.0/networks?recursion=1")? - .as_array() - .into_iter() - .flatten() - .filter_map(|n| Some((n["name"].as_str()?.to_string(), Subnet::from_network(n)?))) - .collect(); let instances = list(client)?; - if let Some(p) = only { - let mine = |i: &Value| i["project"].as_str() == Some(p); - let used: BTreeSet<&str> = instances - .iter() - .filter(|i| mine(i)) - .filter_map(|i| i["expanded_devices"].as_object()) - .flat_map(|d| d.values().filter_map(|n| n["network"].as_str())) - .collect(); - let used: BTreeSet = used.into_iter().map(String::from).collect(); - nets.retain(|n, _| used.contains(n)); + // Only the bridges isb's instances are on, one by one: listing every + // network with `recursion=1` takes incusd seconds per call (each one's + // state from the host), and a host has an egress bridge per sandbox. + let mut used: BTreeSet<&str> = BTreeSet::new(); + for i in &instances { + let project = i["project"].as_str().unwrap_or("default"); + if OrgId::from_incus_project(project).is_none() || only.is_some_and(|p| p != project) { + continue; + } + let devs = i["expanded_devices"].as_object().into_iter().flatten(); + used.extend( + devs.filter(|(_, d)| d["type"] == "nic") + .filter_map(|(_, d)| d["network"].as_str()), + ); + } + let mut nets: BTreeMap = BTreeMap::new(); + for n in used + .into_iter() + .filter(|n| !n.starts_with(crate::egress::plumb::NET_PREFIX)) + { + let path = format!("/1.0/networks/{}", encode_segment(n)); + if let Some(s) = client + .get_opt(&path)? + .as_ref() + .and_then(Subnet::from_network) + { + nets.insert(n.to_string(), s); + } } let mut findings = Vec::new(); for (network, subnet) in &nets { diff --git a/docs/reference/rpc.md b/docs/reference/rpc.md index cf448bb..2c148e0 100644 --- a/docs/reference/rpc.md +++ b/docs/reference/rpc.md @@ -19,7 +19,7 @@ it; relative paths resolve against that directory. When it starts, the server writes one hello line: ```json -{"isb": "4.1.1", "protocol": 1} +{"isb": "4.1.2", "protocol": 1} ``` A client checks `protocol` and refuses versions it does not know. @@ -205,7 +205,7 @@ All take `files` (default `./isb.yaml` plus `./isb.override.yaml` if present), ## Example session ```text -<- {"isb":"4.1.1","protocol":1} +<- {"isb":"4.1.2","protocol":1} -> {"id":1,"method":"sandbox.ensure","params":{"spec":{"name":"web","image":"dev-base","cpus":2}}} <- {"id":1,"event":"progress","data":"web: creating from dev-base"} <- {"id":1,"event":"progress","data":"web: starting"} diff --git a/sdk/python/pyproject.toml b/sdk/python/pyproject.toml index f86d103..36f20f5 100644 --- a/sdk/python/pyproject.toml +++ b/sdk/python/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "isb-sdk" -version = "4.1.1" +version = "4.1.2" description = "Python SDK for isb: declarative incus sandboxes (containers and VMs)" readme = "README.md" license = "MIT AND LicenseRef-EXA-SL-1.0" diff --git a/sdk/python/src/isb/__init__.py b/sdk/python/src/isb/__init__.py index dadd65e..99b106a 100644 --- a/sdk/python/src/isb/__init__.py +++ b/sdk/python/src/isb/__init__.py @@ -62,7 +62,7 @@ async def main(): from ._util import Duration from .volumes import Volumes -__version__ = "4.1.1" +__version__ = "4.1.2" __all__ = [ "PROTOCOL", diff --git a/sdk/python/tests/test_unit.py b/sdk/python/tests/test_unit.py index 4c06942..0e59cb1 100644 --- a/sdk/python/tests/test_unit.py +++ b/sdk/python/tests/test_unit.py @@ -222,7 +222,7 @@ async def test_death_fails_pending_requests(self) -> None: path = fake_server( self.tmp.name, """\ - echo '{"isb":"4.1.1","protocol":1}' + echo '{"isb":"4.1.2","protocol":1}' read line echo "boom" >&2 exit 3 @@ -243,7 +243,7 @@ async def test_close_fails_pending(self) -> None: path = fake_server( self.tmp.name, """\ - echo '{"isb":"4.1.1","protocol":1}' + echo '{"isb":"4.1.2","protocol":1}' cat >/dev/null """, ) @@ -261,7 +261,7 @@ async def test_events_and_out_of_order_replies(self) -> None: path = fake_server( self.tmp.name, """\ - echo '{"isb":"4.1.1","protocol":1}' + echo '{"isb":"4.1.2","protocol":1}' read a read b echo 'not json' diff --git a/sdk/python/uv.lock b/sdk/python/uv.lock index 9b3b40e..16e1ee1 100644 --- a/sdk/python/uv.lock +++ b/sdk/python/uv.lock @@ -72,7 +72,7 @@ wheels = [ [[package]] name = "isb-sdk" -version = "4.1.1" +version = "4.1.2" source = { editable = "." } [package.dev-dependencies] diff --git a/sdk/typescript/bun.lock b/sdk/typescript/bun.lock index 8abe00d..2695ebc 100644 --- a/sdk/typescript/bun.lock +++ b/sdk/typescript/bun.lock @@ -12,8 +12,8 @@ "typescript": "^5.9.0", }, "optionalDependencies": { - "@execution-associates/isb-linux-arm64": "4.1.1", - "@execution-associates/isb-linux-x64": "4.1.1", + "@execution-associates/isb-linux-arm64": "4.1.2", + "@execution-associates/isb-linux-x64": "4.1.2", }, }, }, diff --git a/sdk/typescript/npm/linux-arm64/package.json b/sdk/typescript/npm/linux-arm64/package.json index 34f0b12..2acd2a9 100644 --- a/sdk/typescript/npm/linux-arm64/package.json +++ b/sdk/typescript/npm/linux-arm64/package.json @@ -1,6 +1,6 @@ { "name": "@execution-associates/isb-linux-arm64", - "version": "4.1.1", + "version": "4.1.2", "description": "The static isb binary for Linux arm64 (aarch64-unknown-linux-musl), used by @execution-associates/isb", "license": "SEE LICENSE IN LICENSE", "repository": { diff --git a/sdk/typescript/npm/linux-x64/package.json b/sdk/typescript/npm/linux-x64/package.json index c7a45e2..00cd740 100644 --- a/sdk/typescript/npm/linux-x64/package.json +++ b/sdk/typescript/npm/linux-x64/package.json @@ -1,6 +1,6 @@ { "name": "@execution-associates/isb-linux-x64", - "version": "4.1.1", + "version": "4.1.2", "description": "The static isb binary for Linux x64 (x86_64-unknown-linux-musl), used by @execution-associates/isb", "license": "SEE LICENSE IN LICENSE", "repository": { diff --git a/sdk/typescript/package.json b/sdk/typescript/package.json index 619fab1..81b6a20 100644 --- a/sdk/typescript/package.json +++ b/sdk/typescript/package.json @@ -1,6 +1,6 @@ { "name": "@execution-associates/isb", - "version": "4.1.1", + "version": "4.1.2", "description": "TypeScript SDK for isb: declarative incus sandboxes (containers and VMs)", "license": "MIT", "type": "module", @@ -51,8 +51,8 @@ "prepack": "bun run build" }, "optionalDependencies": { - "@execution-associates/isb-linux-arm64": "4.1.1", - "@execution-associates/isb-linux-x64": "4.1.1" + "@execution-associates/isb-linux-arm64": "4.1.2", + "@execution-associates/isb-linux-x64": "4.1.2" }, "devDependencies": { "@biomejs/biome": "^2.2.0",