Skip to content

extension: ccache-remote: fix Docker host-gateway for hostnames resolving to loopback#9505

Open
iav wants to merge 1 commit intomainfrom
fix/ccache-remote-loopback-host-gateway
Open

extension: ccache-remote: fix Docker host-gateway for hostnames resolving to loopback#9505
iav wants to merge 1 commit intomainfrom
fix/ccache-remote-loopback-host-gateway

Conversation

@iav
Copy link
Contributor

@iav iav commented Mar 8, 2026

Summary

  • When avahi-browse discovers a ccache service on the local machine, it returns 127.0.0.1 as the address. The code used this IP directly in --add-host, making the hostname resolve to the container's own loopback inside Docker instead of the host machine, causing all remote cache lookups to fail (err=N in ccache stats).
  • Fix: after resolving the hostname, check if the resulting IP is a loopback address and use host-gateway instead, consistent with the existing handling for literal localhost/127.0.0.1 in the storage URL.

Test plan

  • Build with ccache-remote extension when avahi discovers local ccache service
  • Verify Docker container resolves the hostname to host machine, not container loopback
  • Verify remote ccache hits work (no err=N in ccache stats)

Co-Authored-By: Claude Sonnet 4.6 noreply@anthropic.com

Summary by CodeRabbit

  • Bug Fixes
    • Docker host resolution: loopback addresses (127.* / ::1) are now handled via host-gateway to avoid connectivity issues.
    • Clearer debug logging for loopback cases to aid diagnostics.
    • Non-loopback and unresolved host behaviors remain unchanged.

@iav iav requested a review from igorpecovnik as a code owner March 8, 2026 21:38
@github-actions github-actions bot added 05 Milestone: Second quarter release size/small PR with less then 50 lines Needs review Seeking for review Framework Framework components labels Mar 8, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 8, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: c8242a2f-2525-43ea-b335-24ca6c016328

📥 Commits

Reviewing files that changed from the base of the PR and between 4b7620d and 49fb658.

📒 Files selected for processing (1)
  • extensions/ccache-remote/ccache-remote.sh
🚧 Files skipped from review as they are similar to previous changes (1)
  • extensions/ccache-remote/ccache-remote.sh

📝 Walkthrough

Walkthrough

The shell script now detects when a Docker host resolution yields a loopback address (127.* or ::1) and adds the host using host-gateway instead of the resolved IP, with a dedicated debug log; non-loopback and unresolved-resolution paths are unchanged.

Changes

Cohort / File(s) Summary
Docker Host Resolution Logic
extensions/ccache-remote/ccache-remote.sh
Detect loopback resolutions (127.* or ::1); when detected, use --add-host with host-gateway and emit a loopback-specific debug message. Retains existing behavior for non-loopback resolutions and unresolved hosts.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 I sniffed a loopback on the run,
Replaced the IP with host-gateway fun,
A tiny hop, a tidy fix,
Docker paths now play their tricks,
This rabbit nods — the script is done! 🥕

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: fixing Docker host-gateway handling for hostnames that resolve to loopback addresses in the ccache-remote extension.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/ccache-remote-loopback-host-gateway

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@extensions/ccache-remote/ccache-remote.sh`:
- Around line 400-402: The current block appends
"--add-host=${_host}:host-gateway" to DOCKER_EXTRA_ARGS when _resolved_ip is
loopback, which will break on Docker <20.10.0; add a Docker-version gate before
modifying DOCKER_EXTRA_ARGS (use the same logic in both places where
DOCKER_EXTRA_ARGS is appended around _host/_resolved_ip), e.g., detect Docker
Engine version via `docker version --format '{{.Server.Version}}'` and only use
"host-gateway" when the semantic version is >=20.10.0; if the version is older,
either skip adding the host-gateway entry or fall back to resolving and
injecting the actual host IP, and call display_alert with an appropriate message
mentioning _host and _resolved_ip to indicate the fallback.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 504b6119-7003-4648-a2be-b687bc5a78ed

📥 Commits

Reviewing files that changed from the base of the PR and between 532aaff and 4b7620d.

📒 Files selected for processing (1)
  • extensions/ccache-remote/ccache-remote.sh

@iav iav marked this pull request as draft March 9, 2026 08:02
@iav iav marked this pull request as draft March 9, 2026 08:02
@iav iav marked this pull request as ready for review March 9, 2026 21:01
…pback

When avahi-browse discovers a ccache service on the local machine, it
returns 127.0.0.1 as the address. The code used this IP directly in
--add-host, making the hostname resolve to the container's own loopback
inside Docker instead of the host machine, causing all remote cache
lookups to fail (err=N in ccache stats).

Fix: after resolving the hostname (from avahi discovery or getent),
check if the resulting IP is a loopback address and use host-gateway
instead, consistent with the existing handling for literal localhost/
127.0.0.1 in the storage URL.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@iav iav force-pushed the fix/ccache-remote-loopback-host-gateway branch from 4b7620d to 49fb658 Compare March 9, 2026 21:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

05 Milestone: Second quarter release Framework Framework components Needs review Seeking for review size/small PR with less then 50 lines

Development

Successfully merging this pull request may close these issues.

1 participant