Skip to content

Windows: real WSL distro for xtask builds, cancellable pull reads, honor Connection: close (#225) - #259

Open
paopaonyapi-creator wants to merge 1 commit into
libracoder:mainfrom
paopaonyapi-creator:pao/windows-fixes
Open

paopaonyapi-creator wants to merge 1 commit into
libracoder:mainfrom
paopaonyapi-creator:pao/windows-fixes

Conversation

@paopaonyapi-creator

Copy link
Copy Markdown

Windows build + cancellation fixes, and honor client-sent Connection: close (#225)

Two independent fixes, both found by running the repo on a real Windows 11 x64 machine (Windows 11 Pro, WSL2, Ubuntu 24.04):

1. cargo xtask windows-dev picked Docker Desktop's internal WSL distro

On a machine where Docker Desktop is installed, wsl -l -q starts with docker-desktop, and the build failed with exit 127 (bash: Permission denied — the internal distro can't run it). After 0.2.1 the machine also has Kiri's own busybox-like kiri distro, which has no bash either.

  • choose_wsl_distro now skips docker-desktop* and Kiri's own kiri distro, with KIRI_WSL_DISTRO as an explicit override
  • wslpath and the two build scripts are scoped to the chosen distro (they used to run in the default distro, so even a correct script path could break)
  • 6 unit tests cover the selection and argument scoping

2. Cancellable registry reads hung on Windows

The two upstream tests cancel::tests::cancel_ends_a_read_that_is_waiting and registry::tests::a_cancelled_download_stops_at_once_and_leaves_nothing fail on Windows (120 s / 5 s sleeps): a blocking Winsock recv is not reliably woken by another thread's shutdown.

  • Inside a cancellable pull on Windows, await_input runs the socket nonblocking and polls the cancel switch every 100 ms; ureq's real read budget is preserved (a slow 400 ms header delay no longer aborts a pull — a new test a_cancellable_download_keeps_its_read_budget_for_slow_data covers exactly that)
  • Linux and non-cancellable paths are unchanged; kiri-image 42/42 on Windows

3. Honor a client-sent Connection: close (upstream #225)

Reproduced exactly per the issue on the named pipe: POST /containers/x/start with Connection: close answers a body-less 204 and then never closes — Docker.DotNet / Testcontainers for .NET wait for EOF and hang. serve() now stops serving after such a request; the repro that stuck >6 s sees EOF after 22 ms. The docker CLI and the rest of the API are unaffected.

Testing

  • cargo test -p kiri-image --lib: 42 passed (incl. 3 new tests)
  • cargo test -p xtask: 6 passed (5 new)
  • cargo test -p kiri-win: 136 passed
  • End-to-end through \\.\pipe\kiri on the fixed engine: pull/run/exec/logs/stop/rm/volumes/networks/compose all green; SOAK of 100 docker run cycles: 100/100, no leaked containers or build cache

Builds from this branch: cargo xtask windows-dev completes on Windows where main failed, and a WiX 6 MSI built from it installs and upgrades a stock 0.2.0 install in place.

@paopaonyapi-creator

Copy link
Copy Markdown
Author

Test evidence from the Windows machine the fixes were made on (Windows 11 Pro x64, WSL2 Ubuntu 24.04, Docker Desktop installed alongside):

  • cargo test -p kiri-image --lib: 42 passed (incl. the new slow-data budget test)
  • cargo test -p xtask: 6 passed (5 new distro-selection tests)
  • cargo test -p kiri-win: 136 passed
  • End-to-end through \.\pipe\kiri on the rebuilt engine: pull / run / exec / logs / stop / rm / volumes / networks+DNS / compose — all green; SOAK 100x docker run --rm: 100/100, zero leaked containers or build cache
  • Issue Windows: Docker API ignores Connection: close, so a body-less 204 (container start) hangs Testcontainers for .NET #225 repro on the named pipe: stuck >6 s before the fix, EOF after 22 ms after it; docker CLI unaffected
  • cargo xtask windows-dev completes on this machine (it failed on main with exit 127), and a WiX 6 MSI built from the branch upgraded a stock 0.2.0 install in place, working end-to-end after the upgrade.

@paopaonyapi-creator
paopaonyapi-creator force-pushed the pao/windows-fixes branch 2 times, most recently from fe4ddc9 to bc2bf3b Compare November 15, 2026 18:48
@libracoder

Copy link
Copy Markdown
Owner

Thanks @paopaonyapi-creator. This bundles three separate changes, and one of them overlaps with #198:

Please also sign the commits; the repo only merges signed commits. Thanks for the work here.

paopaonyapi-creator pushed a commit to paopaonyapi-creator/kiri that referenced this pull request Nov 15, 2026
A blocking Winsock recv is not reliably woken by another thread's
shutdown, so the upstream cancellation tests hang on Windows. Inside a
cancellable pull on Windows, await_input now runs the socket
nonblocking and polls the cancel switch every 100 ms; ureq's real read
budget is preserved (a slow 400 ms header delay no longer aborts a
pull - a new test covers a slow-data response keeping its budget).
Linux and non-cancellable paths are unchanged.

- cargo test -p kiri-image --lib: 42 passed (incl. 3 new tests)
- cargo test -p kiri-win --bin kiri-win: 136 passed

Split out of libracoder#259 at maintainer request: review the kiri-image change
on its own; the xtask WSL distro selection half follows as a separate
PR. The api.rs Connection: close hunk was removed - libracoder#198 covers it.
@paopaonyapi-creator

Copy link
Copy Markdown
Author

Done — split as requested:

All gates re-run on the rebased branches before pushing:

Both commits are now signed (ssh ed25519). Thanks for the quick review.

AndreKurait added a commit to AndreKurait/asagiri that referenced this pull request Nov 16, 2026
Include the attributed public Kiri #259 adaptation and real socket/HTTP
regressions. The combined Platform candidate now runs all image tests on
Windows as well as macOS and Linux.

Public source: libracoder/kiri#259
Source commit: 99a341254a85cb6b9f6c0f1e3c6f755a471632a2
Asagiri input: 74a46d1

Local image tests: 79 passed on Rust 1.99.1. Full native Windows
qualification remains required before the combined candidate can merge.

Signed-off-by: Andre Kurait <akurait@amazon.com>
paopaonyapi-creator added a commit to paopaonyapi-creator/kiri that referenced this pull request Nov 16, 2026
A blocking Winsock recv is not reliably woken by another thread's
shutdown, so the upstream cancellation tests hang on Windows. Inside a
cancellable pull on Windows, await_input now runs the socket
nonblocking and polls the cancel switch every 100 ms; ureq's real read
budget is preserved (a slow 400 ms header delay no longer aborts a
pull - a new test covers a slow-data response keeping its budget).
Linux and non-cancellable paths are unchanged.

- cargo test -p kiri-image --lib: 42 passed (incl. 3 new tests)
- cargo test -p kiri-win --bin kiri-win: 136 passed

Split out of libracoder#259 at maintainer request: review the kiri-image change
on its own; the xtask WSL distro selection half follows as a separate
PR. The api.rs Connection: close hunk was removed - libracoder#198 covers it.
paopaonyapi-creator added a commit to paopaonyapi-creator/kiri that referenced this pull request Nov 16, 2026
On machines with Docker Desktop, wsl -l -q starts with docker-desktop
and the build failed with exit 127: the internal distro cannot run
bash. After 0.2.1 the machine also has Kiri's own busybox-like kiri
distro, which has no bash either. choose_wsl_distro now skips
docker-desktop* and kiri, with KIRI_WSL_DISTRO as an explicit
override; wslpath and the two build scripts are scoped to the chosen
distro instead of always running in the default one.

6 unit tests cover the selection and argument scoping; cargo test
-p xtask --bin xtask: 6 passed.

Split out of libracoder#259 at maintainer request, so the kiri-image
cancellation change and this build change can be reviewed and tested
separately.
@libracoder

Copy link
Copy Markdown
Owner

@paopaonyapi-creator thanks for this PR. Before it can be reviewed and merged, every commit needs to be signed. GitHub shows these as unsigned: 1cea832. Please sign them (GPG or SSH, with the key added to your GitHub account as a signing key), then force-push. GitHub's guide: https://docs.github.com/en/authentication/managing-commit-signature-verification/signing-commits

paopaonyapi-creator added a commit to paopaonyapi-creator/kiri that referenced this pull request Nov 16, 2026
A blocking Winsock recv is not reliably woken by another thread's
shutdown, so the upstream cancellation tests hang on Windows. Inside a
cancellable pull on Windows, await_input now runs the socket
nonblocking and polls the cancel switch every 100 ms; ureq's real read
budget is preserved (a slow 400 ms header delay no longer aborts a
pull - a new test covers a slow-data response keeping its budget).
Linux and non-cancellable paths are unchanged.

- cargo test -p kiri-image --lib: 42 passed (incl. 3 new tests)
- cargo test -p kiri-win --bin kiri-win: 136 passed

Split out of libracoder#259 at maintainer request: review the kiri-image change
on its own; the xtask WSL distro selection half follows as a separate
PR. The api.rs Connection: close hunk was removed - libracoder#198 covers it.
paopaonyapi-creator added a commit to paopaonyapi-creator/kiri that referenced this pull request Nov 16, 2026
On machines with Docker Desktop, wsl -l -q starts with docker-desktop
and the build failed with exit 127: the internal distro cannot run
bash. After 0.2.1 the machine also has Kiri's own busybox-like kiri
distro, which has no bash either. choose_wsl_distro now skips
docker-desktop* and kiri, with KIRI_WSL_DISTRO as an explicit
override; wslpath and the two build scripts are scoped to the chosen
distro instead of always running in the default one.

6 unit tests cover the selection and argument scoping; cargo test
-p xtask --bin xtask: 6 passed.

Split out of libracoder#259 at maintainer request, so the kiri-image
cancellation change and this build change can be reviewed and tested
separately.
A blocking Winsock recv is not reliably woken by another thread's
shutdown, so the upstream cancellation tests hang on Windows. Inside a
cancellable pull on Windows, await_input now runs the socket
nonblocking and polls the cancel switch every 100 ms; ureq's real read
budget is preserved (a slow 400 ms header delay no longer aborts a
pull - a new test covers a slow-data response keeping its budget).
Linux and non-cancellable paths are unchanged.

- cargo test -p kiri-image --lib: 42 passed (incl. 3 new tests)
- cargo test -p kiri-win --bin kiri-win: 136 passed

Split out of libracoder#259 at maintainer request: review the kiri-image change
on its own; the xtask WSL distro selection half follows as a separate
PR. The api.rs Connection: close hunk was removed - libracoder#198 covers it.
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.

2 participants