Repository navigation
fix(hub): a hub that is still starting is no longer taken for another user's program - #228
Merged
Merged
Conversation
… user's program The hub bound its port before its setup, of which a first `docker version` alone may take 5 s (its timeout) on a busy machine or while Docker Desktop starts. The port took connections it did not answer; the CLI, which waits 3 s for `/hub/ping`, took the hub for another user's program: `devstack hub status`, `devstack ui`, `devstack open` said "port ... answers, but not as a devstack hub of this user" and gave up. Seen as `the_token_goes_only_to_this_users_hub` failing on a loaded Windows machine. The hub now binds its port, and writes hub.json, after its setup: what accepts a connection answers it. The state lock and the token still come first, so `who_answers`' reading of an older hub stays true. A test (unix: a `docker` on PATH that takes 4 s) starts a hub and asks `hub status` as soon as the port takes connections. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
the_token_goes_only_to_this_users_hubfailed locally on a loaded Windows machine (onmaintoo). The cause is a real bug, not only a flaky test.Cause
serve()bound the hub's port before its setup. Part of that setup iswatch_engine, whose firstengine::status("docker")runsdocker versionsynchronously, with a 5 s timeout. While it runs, the OS accepts connections on the port, but nothing answers them. The CLI'swho_answerswaits 3 s for/hub/pingand then reportsListener::Foreign:devstack hub status: "port … answers, but not as a devstack hub of this user"ensure_running()(devstack ui,open,pool shared, …): fails at once with the same message, if the hub was started by someone else (autostart at logon, while Docker Desktop is still starting, say)The test waits only for a TCP connect, then runs
hub status, so it hit the same gap wheneverdocker versionwas slow.Fix
The hub binds its port and writes
hub.jsonafter its setup, just before it serves: what accepts a connection answers it. The state lock and the token still come before the bind, so the legacy reading inwho_answers("a hub takes the lock before it binds the port") stays true.Tests
a_hub_answers_once_its_port_takes_connections(unix only: adockeronPATHthat takes 4 s; on WindowsCommand::new("docker")looks only fordocker.exe).docker.exethat sleeps 4 s:hub status: "port … answers, but not as a devstack hub of this user"cargo test -p devstack --test hub: 14/14 on Windows; fmt, clippy clean.🤖 Generated with Claude Code