Repository navigation
feat: probe reverse-proxy vhosts in get_lab_status - #320
Draft
italovalcy wants to merge 1 commit into
Draft
italovalcy wants to merge 1 commit into
italovalcy wants to merge 1 commit into
Conversation
After a lab instance is created the status page polls /api/lab/status until all k8s resources are ready. When PROXY_DOMAIN is configured the proxied service links only work once the reverse-proxy vhost is served, which can lag behind the pods becoming Running. Augment get_lab_status so that, once all resources are ok, it also probes the candidate reverse-proxy vhosts (the server-side analogue of probeProxyLink() in lab_instance_view.html) and reports each as an extra "Proxy__<host>" status entry. A vhost is reachable when it answers with any HTTP status; an unknown hostname is closed by nginx's default server (return 444) and the request raises. Each request probes once (the client keeps polling); an unreachable vhost is reported "not-ok" only until PROXY_PROBE_MAX_WAIT seconds have elapsed since its backing Service was created, after which we stop gating on it so a vhost that never comes up can't block forever. PROXY_PROBE_MAX_WAIT is configurable and defaults to 30s.
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
After a lab instance is created, the status page polls
/api/lab/status/<id>until all k8s resources are ready and then sends the user to the Lab Instance view. WhenPROXY_DOMAINis configured, the proxied service links only work once the reverse-proxy vhost is actually served, which can lag behind the pods becomingRunning.This augments
get_lab_statusso that, once all resources areok, it also probes the candidate reverse-proxy vhosts — the server-side analogue ofprobeProxyLink()inlab_instance_view.html— and reports each one as an extraProxy__<host>entry in the status result. Because the status page'sallOkcheck iterates the whole result array, the page keeps waiting until the proxied links are ready (no template change needed; theProxy__…names simply don't match a DOM row).Behavior
is_ok.return 444), so the request raises → not reachable. This mirrors the browser'sno-corsopaque-resolve detection.not-okonly untilPROXY_PROBE_MAX_WAITseconds have elapsed since its backing Service was created; past that deadline we stop gating on it (reportok) so a vhost that never comes up can't block the caller forever.PROXY_PROBE_MAX_WAITis configurable (env var), defaults to30s;0disables the probe. No proxy entries / no probing whenPROXY_DOMAINis empty, so existing deployments are unaffected.requests.get(verify=False)with a fixed 5s timeout (mirrors the client's 5s abort) — a reachability check, not a security check, so a served-but-untrusted cert still counts as up.Files
apps/api/routes.py—_build_proxy_urls()(maps each candidate vhost URL to its Service creation timestamp),_probe_proxy_vhost(), and the augmentedget_lab_status.apps/config.py— newPROXY_PROBE_MAX_WAITsetting.tests/test_api_k8s.py— coverage for domain-unset (no probe), reachable →ok, unreachable-within-window →not-ok, deadline-exceeded →ok, probe-skipped-while-not-ready, and a_build_proxy_urlsunit test.Stacking
Stacked on top of #319 (
fix/k8s-exec-apiclient-isolation). Review/merge the base PRs in the stack first; the base should be retargeted tomainas the lower PRs merge.Testing
pytest tests/test_api_k8s.py— 37 passed.🤖 Generated with Claude Code