Use already-running instances when discovery finds nothing#409
Draft
gtsiolis wants to merge 2 commits into
Draft
Use already-running instances when discovery finds nothing#409gtsiolis wants to merge 2 commits into
gtsiolis wants to merge 2 commits into
Conversation
…nothing Co-Authored-By: Claude <noreply@anthropic.com>
gtsiolis
marked this pull request as draft
July 24, 2026 11:09
Member
Author
|
Possibly not worth adding, but wanted to see the PoC in action. Feedback welcome. |
Co-Authored-By: Claude <noreply@anthropic.com>
Contributor
That sounds good. My first instinct was to run the HTTP check in parallel to the container check but I bet the implementation remains must simpler this way.
Yeah, feels like |
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.
Motivation
lstk aws(and the other proxies) could not target a LocalStack running from source: discovery was Docker-only (container name, then image match), so a plain-process instance on 4566 was invisible and every command pushed the user to start a container — reported by Duncan for the internal dev loop, but equally affecting hand-started containers with unknown images and remote instances viaLOCALSTACK_HOST. The same gate also brokelstk az start-interceptionagainst a debug/host-mode Azure emulator (reported by Paolo), since it shares the proxy discovery path.What changed
When Docker discovery finds nothing — or Docker is unavailable — lstk now probes
GET /_localstack/infoon the resolved host and silently attaches if a LocalStack instance answers (200 + JSON + non-empty version). The probe only runs on paths that errored before, so container flows are byte-for-byte unchanged and success paths gain no latency. This generalizes the attach precedent thatlstk start's port-conflict fallback already had; that path now shares the same probe.aws,az(incl.start-interception),terraform/cdk/sam,reset,snapshot save/load(incl. S3 save/load).lstk terraformwith only Snowflake up).snapshot load's Docker auto-start runs only when Docker is healthy and nothing is reachable; an external instance is used as-is.stop,logs,restart,status,snapshot list s3:///removestay Docker-gated (follow-up: external-awarestatus+ truthful "running, but not started by lstk" errors for stop/logs).container.ProbeEmulatorInfo,container.ResolveEmulator,container.FirstReachableEmulator,cmd/emulator.go:resolveReachableEmulator.Testing
external_instance_test.go, no Docker needed): aws/terraform/az/reset/snapshot-save/snapshot-load against a mock/_localstack/infoserver with a deadDOCKER_HOST— the aws case fails on main with "Docker is not available".lstk az start-interceptionagainst a host-run Azure emulator (Paolo's debug-mode report): the sharedazPreflightnow finds the external instance instead of reporting "not running". Pinned byTestAzStartInterceptionUsesExternalInstance, which asserts the command gets past Docker-only discovery and reaches the interception reachability check; verified red→green against the pre-fix binary (pre-fix: "Docker is not available"). The full interception (global~/.azuremutation) needs the emulator's TLS gateway + wildcard DNS and stays covered byTestSetupAzureAndAzCommandSucceed.LOCALSTACK_HOSTso they stay deterministic on machines with a real LocalStack on 4566.LOCALSTACK_AUTH_TOKEN, and environment-specific ones — verified identical against a pre-change binary).uv run -m localstack.runtime.main),lstk aws s3 mb/ls,lstk reset --force, andlstk snapshot saveall succeed; the pre-change binary fails the same setup with "Docker is not available".lstk stopstill errors truthfully.Review
New user-facing behavior on five proxy commands plus reset/snapshot — human review advisable. The riskiest spots are the Docker-down error-precedence changes in
FirstReachableEmulator/resolveReachableEmulatorand the silent-attach semantics.Closes DEVX-1016
Co-Authored-By: Claude noreply@anthropic.com