Synced from Hive. This page is pulled from hivecommons/hive@v5 during the docs build. Edit the canonical source in the Hive repository.
Opening a hive that is down or upgrading
While a hosted hive’s pod is down, upgrading or restarting, nothing is there to serve the hive’s own “starting” screen. Without help, a browser sent to the hive sees whatever sits in front of it: the OpenShift router’s “Application is not available”, or the nginx controller’s stock 503. Two layers replace that with a hive-branded page (#20912).
| Layer | Covers | Where |
|---|---|---|
Hub gate on /open | Every hive opened from the hub, on every cluster type | src/pkg/hub/open_gate.go |
| Ingress error fallback | Direct visits to hosted hives on nginx-ingress clusters | src/pkg/hub/saas_provision.go, src/deploy/k8s/error-pages.yaml |
1. Hub gate on /open
GET /api/saas/hives/{id}/open is the SSO handoff every hub “open hive” link
uses. After its access check passes, and before it mints the SSO token, the hub
decides whether the spoke can take the browser:
- The hub probes the spoke: an unauthenticated
GET <dashboard URL>/robots.txtwith a 3 second timeout and no redirect following. The spoke answers that path before authentication and the hub’s ingress auth-check lets it through, so the answer comes from the pod (or, if there is no pod, from the router or ingress), never from the auth layer. The probe uses the hub’s SSRF-guarded transport, so a dashboard URL on a private address is never fetched. Answers are reused for 3 seconds; a probe that could not complete is remembered for 5 minutes so hub-unreachable spokes do not pay the timeout on every click. - Only 502, 503, 504 (or a CDN’s 520-524) mean “not serving”. Every other status, including a probe that could not complete at all, lets the navigation through. The hub cannot reach every spoke (some clusters are firewalled from it), and the gate must never hold a working hive behind a waiting page.
- The upgrade flag only changes the wording. When the registry entry has
upgradingset with anupgradeStartedAtyounger than the stuck-upgrade window (10 minutes), a not-serving hive is described as upgrading to the target version. It does not gate on its own: an armed upgrade waits for the next heartbeat and a drain while the old pod keeps serving.
When the hive is not ready the hub answers 200 with its own page instead of
the redirect. 200 is deliberate: the hub’s own Ingress would replace a 5xx
with the generic error backend page. The page:
- says the hive is upgrading (naming the target version when known) or starting;
- polls
GET /api/saas/hives/{id}/open-status({ready, upgrading, targetVersion}), starting at 3 seconds and backing off by 1.5x to 30 seconds; - once ready, continues through
/openagain with the original query string and URL fragment, so the normal SSO handoff runs with a fresh token; - after 10 minutes (counted across reloads of the page in the same tab) shows “still not up” with a Contact the operator link
(
HIVE_SUPPORT_URL, default the project issue tracker) and keeps polling once a minute; - always offers Open anyway (
/open?open_anyway=1), which skips the gate but not the access check.
Who sees what
The gate runs after the same access check /open always applied (hive owner,
granted user or hub admin). A signed-in user without access still gets the
plain 403 {"error":"access denied"}, and the probe never runs for them. The
status endpoint checks access before looking anything up, so for such a user
it answers the same 403 for a hive that is up, one that is down and one that
does not exist. A signed-out caller gets 401.
2. Ingress error fallback (nginx-ingress clusters)
Each hosted hive on an nginx-ingress cluster gets several Ingress objects. Their error interception is:
| Ingress | Paths | custom-http-errors | Why |
|---|---|---|---|
hive | / (pages) | 502,503,504 | Nothing on page paths answers these on purpose; /sso fails with 4xx so it is never intercepted |
hive-api-xhr | /api | 401,502,503 | The spoke answers some /api calls with a JSON 504 (backup timeout, workflow dispatch, TTS); intercepting it would replace that detail with “hive unavailable” |
hive-contribute | /api/contribute | 502,503 | JSON consumers, same reasoning |
hive-terminal | /terminal | none | A websocket; an HTML page is no use to it |
hive-api | /api/v1 | not set, inherits the controller’s global list | Bearer-token API |
Each intercepting Ingress also carries
nginx.ingress.kubernetes.io/default-backend: hive-error-pages. The shared
backend (src/deploy/k8s/error-pages.yaml, namespace ingress-nginx) serves the
branded “Hive is starting” page to browsers and an {"ok":false,...} JSON body
to API callers, and always reproduces the intercepted status (it never answers
200).
503 and the hive’s own 503s
ingress-nginx cannot tell a 503 it generated (no ready endpoint, the upgrade window) from a 503 the pod sent. Both are intercepted on an Ingress that lists 503. That is why each list is per Ingress and as narrow as its paths allow: page paths never send an intentional 503 (the SSO handoff was changed to 4xx for exactly this reason, #16652), while the JSON Ingresses already accepted that a spoke 503 comes back as the backend’s JSON 503. 500 and every 4xx other than the XHR 401 always pass through unchanged.
Controller requirements
custom-http-errorsanddefault-backendare standard annotations; they do not needallow-snippet-annotations, which stays disabled.- ingress-nginx resolves the per-Ingress
default-backendService in the Ingress’s own namespace. Hosted hive namespaces have nohive-error-pagesService, so the controller falls back to its global default backend. The controller must therefore run with--default-backend-service=ingress-nginx/hive-error-pages(Helm:controller.extraArgs.default-backend-service), or intercepted statuses get the controller’s stock page. - Keep the controller ConfigMap’s global
custom-http-errorsat502,503,504(see the comment inerror-pages.yaml, #17431).
Applying it to a cluster
New hives get the annotations from the template. For a cluster that already runs hosted hives:
CTX=<kube context of the nginx-ingress cluster>
# 1. Shared error backend (idempotent).
kubectl --context "$CTX" apply -f src/deploy/k8s/error-pages.yaml
kubectl --context "$CTX" -n ingress-nginx rollout status deploy/hive-error-pages
# 2. Controller points its default backend at it. Expect
# --default-backend-service=ingress-nginx/hive-error-pages in the output.
kubectl --context "$CTX" -n ingress-nginx get deploy ingress-nginx-controller \
-o jsonpath='{.spec.template.spec.containers[0].args}' | tr ',' '\n' | grep default-backend
kubectl --context "$CTX" -n ingress-nginx get cm ingress-nginx-controller \
-o jsonpath='{.data.custom-http-errors}{"\n"}'
# 3. Existing hive page Ingresses pick up 504.
kubectl --context "$CTX" get ingress -A --field-selector metadata.name=hive -o json \
| jq -r '.items[] | select(.metadata.annotations["nginx.ingress.kubernetes.io/default-backend"] == "hive-error-pages") | .metadata.namespace' \
| while read -r ns; do
kubectl --context "$CTX" -n "$ns" annotate ingress hive --overwrite \
nginx.ingress.kubernetes.io/custom-http-errors=502,503,504
done
If step 2 shows no --default-backend-service flag, add it through the
controller’s Helm values (controller.extraArgs.default-backend-service: ingress-nginx/hive-error-pages) and roll the controller.
To check a hive end to end, scale it to zero and request its page: the answer
must be 503 with the “Hive is starting” HTML, and an /api/ request must get
the JSON body.
OpenShift clusters
Hives on OpenShift use Routes, and the router’s error pages are left alone. Only the hub gate applies there: a hive opened from the hub shows the hub’s waiting page, but a direct visit to the hive URL during an upgrade or restart still shows the router’s “Application is not available” page until the pod is back.