Skip to content

fix: detect silent wget failures in container DownloadFile#743

Open
dlevy-msft-sql wants to merge 4 commits intomicrosoft:mainfrom
dlevy-msft-sql:fix/silent-wget-failure
Open

fix: detect silent wget failures in container DownloadFile#743
dlevy-msft-sql wants to merge 4 commits intomicrosoft:mainfrom
dlevy-msft-sql:fix/silent-wget-failure

Conversation

@dlevy-msft-sql
Copy link
Copy Markdown
Contributor

Problem

\DownloadFile\ discarded wget's stdout/stderr, so failed downloads (e.g. unreachable host, DNS failure, 404) produced no error. The caller then tried to restore a missing or empty .bak\ file, yielding a confusing \The volume on device '...' is empty\ message from SQL Server.

Fix

After wget completes, verify the output file exists and is non-empty via \ est -s. If the file is missing or empty, panic with the wget stderr output for diagnosis. This stays consistent with the existing panic-based precondition pattern in the container package.

Also:

  • \mkdir\ -> \mkdir -p\ for idempotent directory creation
  • Updated test to expect panic on unreachable localhost URL (httptest binds to 127.0.0.1 which containers can't reach)

What changed

Fixes #566

@dlevy-msft-sql dlevy-msft-sql added this to the v1.11 milestone Apr 17, 2026
@dlevy-msft-sql dlevy-msft-sql force-pushed the fix/silent-wget-failure branch from 5c04558 to 8a5de5a Compare April 17, 2026 16:41
DownloadFile discarded wget's exit code, so failed downloads (e.g.
unreachable host) produced no error. The caller then tried to restore
a missing or empty .bak file, yielding a confusing 'volume is empty'
message from SQL Server.

Add ExecInspect to runCmdInContainer to capture the exit code. Check
wget's exit code in DownloadFile and panic with stderr context on
failure.

Also adds mkdir -p for idempotent directory creation.

Fixes microsoft#566
@dlevy-msft-sql dlevy-msft-sql force-pushed the fix/silent-wget-failure branch from 8a5de5a to feaae22 Compare April 17, 2026 16:44
- Add ExtraHosts host-gateway mapping to ContainerRun so containers can
  resolve host.docker.internal to the Docker host
- Update TestController_EnsureImage to replace 127.0.0.1/localhost with
  host.docker.internal so wget inside the container can reach the host's
  httptest server in CI
httptest.NewServer binds to 127.0.0.1, which is unreachable from the
Docker bridge network even with host.docker.internal. Use NewUnstartedServer
with a 0.0.0.0 listener so the container can connect via 172.17.0.1.
Use net.Listen tcp4 + net.SplitHostPort to extract the port and build
the host.docker.internal URL directly. Avoids fragile string replacements
that miss IPv6 [::] addresses on some CI runners.
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.

Bak restore from local http server corrupted file

1 participant