Skip to content

Resolve the GCE machine type at startup, not in a handler - #44

Open
0bserver07 wants to merge 1 commit into
tobi:mainfrom
0bserver07:fix/machine-type-probe-off-the-runtime
Open

Resolve the GCE machine type at startup, not in a handler#44
0bserver07 wants to merge 1 commit into
tobi:mainfrom
0bserver07:fix/machine-type-probe-off-the-runtime

Conversation

@0bserver07

Copy link
Copy Markdown
Contributor

gce_machine_type() in crates/walgit-server/src/instance.rs forked curl inside a OnceLock::get_or_init, and instance::info() reaches it from every readiness and health handler (health.rs lines 29, 36 and 42) and the UI footer, so the first such request on an SSD host held a tokio worker for up to 300 ms on a subprocess. That's the tell principle VI names: a Command::new(...).output() on the async runtime.

The probe is now a reqwest GET of the same URL with the same header, 300 ms budget and parsing, awaited once in serve() before the listener accepts, and only on the host that calls itself ssd (WALGIT_INSTANCE_KIND=ssd, or maintenance.disk = "ssd" with no explicit kind), which is the one shape whose info() prints a machine type and the only place the old code probed. Handlers now read the cell and nothing else; when the probe never ran, info() falls back to the cpu and memory shape exactly as it did when curl failed. One unit test asserts a non-SSD host caches nothing and touches no network.

Checked with cargo clippy -p walgit-server --all-targets --no-deps -- -D warnings, cargo test -p walgit-server --lib (72 pass), cargo test -p walgit-server --test drain --test api_v1 and cargo fmt --all -- --check. Not exercised on a real GCE VM; the request is byte for byte what curl sent.

gce_machine_type in crates/walgit-server/src/instance.rs forked curl inside
a OnceLock::get_or_init, and info() reaches it from every readiness and
health handler and the UI footer, so the first such request on an SSD host
held a tokio worker for up to 300 ms on a subprocess. That is the tell
principle VI names, a Command::new(...).output() on the async runtime. The
probe is now a reqwest GET of the same URL with the same header, timeout and
parsing, awaited once in serve() before the listener accepts, and only on the
host that calls itself ssd (WALGIT_INSTANCE_KIND=ssd, or maintenance.disk =
"ssd" with no explicit kind), which is the one shape whose info() prints a
machine type and the only place the old code probed. Handlers now read the
cell and nothing else; when the probe never ran, info() falls back to the
cpu and memory shape exactly as it did when curl failed. Checked with
cargo clippy -p walgit-server --all-targets --no-deps -- -D warnings, cargo
test -p walgit-server --lib (the new test asserts a non-SSD host caches
nothing and touches no network), cargo test -p walgit-server --test drain and
cargo fmt --all -- --check.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CSbhRh6UEjFrgBYYzucvDe
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.

1 participant