Add Docker host fallback for localhost provider endpoints#63
Merged
Conversation
When CLK runs in a container, http://localhost:... cannot reach an ollama or OpenWebUI server bound to the host. Probe the same port on host.docker.internal; if only that answers, warn and offer to rewrite .env. Runs during the openwebui install branch, the ollama/openwebui configure flows, and as a standalone setup step that fires regardless of the active provider so the TUI's all-providers health check stops flagging the host's ollama as UNAVAILABLE.
Ollama and OpenWebUI providers now probe their configured endpoint at runtime and, if a localhost URL is dead but the host.docker.internal equivalent answers, transparently switch self.config['endpoint'] and log a one-line notice. The TUI provider-health pass snapshots endpoints, detects the swap inside available_providers (which mutates the shared providers_cfg dict), and persists the change to providers.json so the fix survives across runs.
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.
Summary
When CLK runs inside a Docker container, HTTP endpoints configured as
http://localhost:PORTcannot reach services (ollama, OpenWebUI) running on the host machine. This PR adds automatic fallback tohost.docker.internalwhen localhost endpoints are unreachable, with detection and persistence of the swap across the codebase.Key Changes
New module
clk_harness/providers/_endpoint_fallback.py: Centralizes Docker host fallback logic with three main functions:probe_endpoint(): Tests TCP connectivity to an endpoint with timeoutdocker_host_swap(): Converts localhost URLs to host.docker.internal equivalentsmaybe_docker_host_fallback(): Probes both endpoints and logs a one-time notice if fallback is neededProvider updates (
ollama.py,openwebui.py):available()methods to use the new fallback utilitiesInstallation script (
scripts/install_tool.sh):_it_probe_endpoint()helper for endpoint reachability checks_it_offer_docker_host_fallback()to interactively prompt users during setupKickoff script (
kickoff.sh):docker_host_fallbackstep that probes endpoints early in the setup process.envfile when fallback is neededTUI integration (
clk_harness/tui.py):providers.jsonImplementation Details
https://claude.ai/code/session_019H5FnEyiYvomB64pFyozsK