Use already-running instances when discovery finds nothing - #409
Use already-running instances when discovery finds nothing#409gtsiolis wants to merge 2 commits into
Conversation
|
Possibly not worth adding, but wanted to see the PoC in action. Feedback welcome. |
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 |
|
I'd suggest we add |
00cfad0 to
2cba4f0
Compare
2cba4f0 to
7d4f0e5
Compare
…nothing Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
7d4f0e5 to
f8b3986
Compare
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