Skip to content

fix(k8s): fail fast in /info when the API server does not answer - #119

Merged
oleksandr-nc merged 2 commits into
mainfrom
fix/k8s-info-probe
Sep 8, 2026
Merged

fix(k8s): fail fast in /info when the API server does not answer#119
oleksandr-nc merged 2 commits into
mainfrom
fix/k8s-info-probe

Conversation

@oleksandr-nc

Copy link
Copy Markdown
Contributor

The /info probe of the Kubernetes API server inherited K8S_HTTP_TIMEOUT (60 s). AppAPI waits 5 s for /info in its daemon checks, so an unreachable API server surfaced as "Cannot reach HaRP: cURL error 28" after a 5 s hang on every admin page load and Check connection.

The probe now has its own 3 s timeout (has to stay below AppAPI's 5 s) and /info reports why the cluster is unreachable in a new error field, e.g. HTTP 401 with a token hint, TLS error, connection refused, or timeout. reachable keeps its meaning, so current AppAPI releases are unaffected.

Tested against a kind cluster with the API server paused: /info 60 s -> 3 s, AppAPI daemon check 5.3 s with the wrong message -> 3.3 s with the right one; ExApp deploy/disable/enable/unregister through the patched HaRP unchanged.

The /info probe inherited the 60 s K8S_HTTP_TIMEOUT. AppAPI waits 5 s for /info in its daemon checks, so an unreachable API server surfaced as "Cannot reach HaRP" after a 5 s hang on every admin page load. The probe now has its own 3 s timeout and /info reports why the cluster is unreachable in a new "error" field.

Signed-off-by: Oleksandr Piskun <oleksandr2088@icloud.com>
@coderabbitai

coderabbitai Bot commented Sep 8, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

Warning

Review limit reached

Next included review available in 18 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: a401d133-9c6f-4ca1-9e84-a7e4394a2444

📥 Commits

Reviewing files that changed from the base of the PR and between 45808f7 and 9515073.

📒 Files selected for processing (1)
  • haproxy_agent.py
📝 Walkthrough

Walkthrough

The change adds a three-second Kubernetes API probe timeout. The new _k8s_probe() helper checks Kubernetes configuration, requests /api, and preserves detailed failure reasons. The /info endpoint now uses this helper and reports both reachable and an optional error field.

Priority: ⬇️ Low — Defer this Kubernetes /info probe change because it is a focused timeout and error-reporting improvement without elevated product-impact evidence.

Merge Risk: 🔵 Low · up to 45808

The /info endpoint now performs a short Kubernetes probe and returns failure details. Repeated checks may create unnecessary connections, and HTTP 403 messages may direct operators toward token troubleshooting instead of RBAC permissions; both should be corrected before merge.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: making the Kubernetes API probe fail fast in the /info endpoint.
Description check ✅ Passed The description directly explains the dedicated timeout, the new error reporting, compatibility behavior, and test results for the changeset.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: a2f84e58-7ec1-47c1-97c4-12d40308e2ba

📥 Commits

Reviewing files that changed from the base of the PR and between 93afc12 and 45808f7.

📒 Files selected for processing (1)
  • haproxy_agent.py

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.

Comment thread haproxy_agent.py
Comment thread haproxy_agent.py Outdated
Comment thread haproxy_agent.py
Address review feedback on the probe added in the previous commit:

- read the response body inside the request context, like `_k8s_request`
  already does, and append it (truncated to 200 chars) to the error. The
  Kubernetes `Status.message` names the actual problem, e.g. `forbidden:
  User "..." cannot get path "/api"`. Leaving the body unread also made
  aiohttp drop the pooled connection whenever the body did not arrive with
  the headers, which is exactly the degraded API server this probe targets.
- report HTTP 401 and 403 separately: 401 is authentication, so the bearer
  token hint is right; 403 is authorization, where a valid token is denied
  by RBAC and the token hint sends operators the wrong way.
- add the missing docstring to `get_info`.

Signed-off-by: Oleksandr Piskun <oleksandr2088@icloud.com>
@oleksandr-nc
oleksandr-nc merged commit 618751a into main Sep 8, 2026
17 checks passed
@oleksandr-nc
oleksandr-nc deleted the fix/k8s-info-probe branch September 8, 2026 17:24
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