Skip to content

Wait for proxy readiness before starting updater - #658

Open
brettfo wants to merge 1 commit into
mainfrom
dev/brettfo/proxy-readiness
Open

brettfo wants to merge 1 commit into
mainfrom
dev/brettfo/proxy-readiness

Conversation

@brettfo

@brettfo brettfo commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Why

The proxy can perform synchronous NuGet service-index discovery before it binds port 1080. A running proxy container therefore does not guarantee that the proxy is ready, and the collector or updater can start too early.

The CLI can run on Windows, macOS, or Linux, and custom proxy images should not need to add a readiness-specific executable or place their shell at /bin/sh.

What changed

  • Inspect /proc/net/tcp and /proc/net/tcp6 inside the Linux proxy container through Docker's exec API before creating the collector or updater.
  • Use only sh built-ins, resolving sh through the image's PATH just as proxy startup does.
  • Avoid requiring nc, grep, or another additional executable in custom proxy images.
  • Keep the credential-injecting proxy private to Docker networks rather than publishing it to a host socket.
  • Poll every 100 ms for up to 60 seconds and wait for each probe process to finish before inspecting its exit code.
  • Keep the internal readiness deadline from being classified as the user-configured update timeout, while preserving genuine parent-context deadlines and probe errors.
  • Preserve the primary readiness or updater error when proxy cleanup also fails.
  • Add unit coverage for readiness polling and timeout/error classification.
  • Add Docker-backed coverage using a custom proxy image with no nc and no /bin/sh, proving updater startup waits for a delayed listener and failed updater connectivity aborts the fixture.

This provides the same startup sequencing guarantee as github/dependabot-action#1757 while remaining independent of the CLI host operating system and additional custom-image tooling.

Testing

  • go test ./internal/...
  • All non-script-test packages via go test after excluding cmd/dependabot
  • Repeated readiness unit tests with -count=20
  • Docker-backed TestDependabot/proxy with a custom proxy image that has neither nc nor /bin/sh

A full local go test ./... is blocked by the script-test harness exposing only PATH: Docker falls back to its legacy builder and rejects existing COPY --chmod instructions across unrelated fixtures. The targeted Docker test passed using a local legacy-builder-compatible form of the fixture, with no such compatibility change retained in this branch.

@brettfo
brettfo requested review from a team as code owners September 11, 2026 17:05
@brettfo
brettfo force-pushed the dev/brettfo/proxy-readiness branch from a147d4b to 35a0832 Compare September 11, 2026 17:16
@JamieMagee
JamieMagee requested a balanced review from Copilot September 11, 2026 17:20

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The published credential proxy lacks access control, and the integration fixture does not detect failed startup sequencing.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review tier: Balanced
Findings: 1 High severity · 1 Medium severity

New issues introduced by this change (2)
Severity Finding
High severity internal/​infra/​proxy.go — Avoid exposing the credential-injecting proxy without authentication View comment
Medium severity testdata/​scripts/​proxy.txt — Make a failed readiness connection fail the fixture View comment
What changed in this PR

Adds HTTP-level proxy readiness checks before starting dependent containers.

Changes:

  • Publishes a loopback readiness port and polls it via Go HTTP.
  • Preserves primary errors during proxy cleanup.
  • Adds unit and Docker-backed readiness coverage.
File Description
internal/​infra/​proxy.go Implements proxy readiness probing.
internal/​infra/​run.go Waits before starting dependent containers.
internal/​infra/​updater.go Extracts reusable polling and port checks.
internal/​infra/​proxy_test.go Tests HTTP-level readiness.
testdata/​scripts/​proxy.txt Adds delayed-proxy integration coverage.
go.mod Promotes Docker connections to a direct dependency.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread internal/infra/proxy.go Outdated
Comment thread testdata/scripts/proxy.txt
@brettfo
brettfo force-pushed the dev/brettfo/proxy-readiness branch from 35a0832 to 08a8d7c Compare September 11, 2026 17:43
@brettfo
brettfo requested a balanced review from Copilot September 11, 2026 17:44

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The readiness probe breaks custom proxy images that do not provide the previously undeclared nc dependency.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review tier: Balanced
Findings: 1 Medium severity

New issues introduced by this change (1)
Severity Finding
Medium severity internal/​infra/​updater.go — Preserve compatibility with custom proxy images View comment
Issues resolved since last review (2)
Severity Finding
Medium severity testdata/​scripts/​proxy.txt — Make a failed readiness connection fail the fixture View resolved comment
High severity internal/​infra/​proxy.go — Avoid exposing the credential-injecting proxy without authentication View resolved comment

Comment thread internal/infra/updater.go Outdated
@brettfo
brettfo force-pushed the dev/brettfo/proxy-readiness branch from 08a8d7c to 86907ee Compare September 11, 2026 18:06
@brettfo
brettfo requested a balanced review from Copilot September 11, 2026 19:19

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Internal timeout classification and shell-path compatibility can produce incorrect failures.

Get a fresh assessment by requesting another Copilot review.

Review tier: Balanced
Findings: 2 Medium severity

New issues introduced by this change (2)
Severity Finding
Medium severity internal/​infra/​proxy.go — Do not expose the private readiness deadline as the update timeout View comment
Medium severity internal/​infra/​updater.go — Use the same shell contract as proxy startup View comment
Issues resolved since last review (1)
Severity Finding
Medium severity internal/​infra/​updater.go — Preserve compatibility with custom proxy images View resolved comment

Comment thread internal/infra/proxy.go
Comment thread internal/infra/updater.go
Inspect the proxy container socket tables with shell built-ins before creating dependent containers. Avoid publishing the credential-injecting proxy or requiring additional image executables, preserve parent timeout and cleanup errors, support shells resolved through PATH, and add Docker-backed sequencing coverage.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@brettfo
brettfo force-pushed the dev/brettfo/proxy-readiness branch from 86907ee to 9ef7997 Compare September 11, 2026 22:52
@brettfo
brettfo requested a balanced review from Copilot September 11, 2026 22:52

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The key integration test does not deterministically verify startup ordering.

Get a fresh assessment by requesting another Copilot review.

Review tier: Balanced
Findings: 1 Medium severity

Open findings (1)
Resolved findings (2)

Comment thread testdata/scripts/proxy.txt
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