ACM-39212 fix(backend): use GET /api with body drain instead of HEAD [release-2.16] - #6597
Conversation
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: Randy424 The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository: stolostron/coderabbit/.coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
17774ac to
f70b4e5
Compare
|
/test unit-tests-sonarcloud |
1 similar comment
|
/test unit-tests-sonarcloud |
…te response body drain (stolostron#6537) getAuthenticatedToken() called isAuthenticated() on every authenticated request, which issued GET /apis to the kube API. The response body (up to several MB on CRD-heavy clusters) was never consumed on the success path, preventing the socket from returning to the keepAlive pool. Under sustained load, native (external) memory accumulated proportionally to request volume. Replace GET /apis with HEAD /api: - HEAD responses have no message body by HTTP spec — nothing to drain - /api (core group) is ~200 bytes of headers; it does not grow with CRDs - Returns HTTP status so callers preserve 401/403/5xx distinctions - No client-side caching required: OpenShift oauth-apiserver caches valid tokens ~30 seconds server-side; failures are not cached isAuthenticated() now returns Promise<number> (HTTP status) instead of Promise<Response> so callers preserve upstream status codes. authenticated.ts updated accordingly. All route tests updated to mock HEAD /api instead of GET /apis. Signed-off-by: Randy Bruno Piverger <21374229+Randy424@users.noreply.github.com> Co-authored-by: Randy Bruno Piverger <21374229+Randy424@users.noreply.github.com> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
HEAD /api returns 405 on clusters where the API server or proxy chain rejects HEAD requests, causing every auth check to fail. Switch to GET /api with explicit body drain — the response is ~200 bytes (core API group only), drained immediately so the socket returns to the keepAlive pool. This preserves the memory optimization while restoring compatibility. Signed-off-by: Randy Bruno Piverger <21374229+Randy424@users.noreply.github.com> Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Signed-off-by: Randy Bruno Piverger <21374229+Randy424@users.noreply.github.com> Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
fe827df to
4d81762
Compare
|
Rebased onto the latest Conflict: Resolution: Same approach used for the release-2.14 (#6671) and release-2.15 (#6598) backports, itself sourced from how Additional fix: A handful of Verified: all 266 backend tests pass, |
|



Summary
HEAD /apiis rejected by some cluster API server / proxy configurationsisAuthenticated()toGET /apiwith explicit body drain (.resume())/apiresponse is ~200 bytes (vs several MB for/apis), drained immediately so sockets return to the keepAlive poolChanges
backend/src/lib/token.ts: GET /api with body drain, returnsPromise<number>.head('/api')to.get('/api')Test plan
Backport of #6600 to release-2.16
🤖 Generated with Claude Code