Resolve the GCE machine type at startup, not in a handler - #44
Open
0bserver07 wants to merge 1 commit into
Open
Conversation
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
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.
gce_machine_type()incrates/walgit-server/src/instance.rsforkedcurlinside aOnceLock::get_or_init, andinstance::info()reaches it from every readiness and health handler (health.rslines 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: aCommand::new(...).output()on the async runtime.The probe is now a
reqwestGET of the same URL with the same header, 300 ms budget and parsing, awaited once inserve()before the listener accepts, and only on the host that calls itselfssd(WALGIT_INSTANCE_KIND=ssd, ormaintenance.disk = "ssd"with no explicit kind), which is the one shape whoseinfo()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_v1andcargo fmt --all -- --check. Not exercised on a real GCE VM; the request is byte for byte what curl sent.