ACM-40502 fix(backend): use GET /api with body drain instead of GET /apis [release-2.14] - #6671
Conversation
|
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:
Comment |
|
[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 |
…apis [release-2.14] Backport of the memory leak fix to release-2.14. isAuthenticated() was calling GET /apis on every authenticated request and never consuming the response body on the success path. This left sockets stuck outside the keepAlive pool, causing unbounded native (external) memory growth in console-chart-console-v2 pods. Fix: switch to GET /api (~200 bytes vs 35+ KB for /apis which scales with CRDs), drain the response body via .resume() so the socket returns to the keepAlive pool immediately, and return the numeric status so callers no longer hold a Response reference. Signed-off-by: Randy Bruno Piverger <21374229+Randy424@users.noreply.github.com> Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
64dc9b1 to
f373402
Compare
|
Rebased onto the latest Conflict: Resolution: Reviewed how Additional fix: A few other Verified: all 172 backend tests pass, lint clean. |
|



Summary
Backport of the memory leak fix to
release-2.14.isAuthenticated()inbackend/src/lib/token.tswas callingGET /apison every authenticated request and never consuming the response body on the success path. This left sockets stuck outside the keepAlive pool, causing unbounded native (external) memory growth inconsole-chart-console-v2pods.Reproduced at 5,899 MB peak RSS (+5,512 MB above baseline) with 615 stuck sockets under 150 concurrent connections. V8 heap oscillated normally throughout — the leak is entirely in native/external memory outside the GC's reach.
Changes
isAuthenticated()now usesGET /api(~200 bytes) instead ofGET /apis(35+ KB, scales with CRDs)response.body?.on('error', () => undefined).resume()so the socket returns to the keepAlive pool immediatelyPromise<Response>toPromise<number>— callers no longer hold a Response referenceauthenticated.tsupdated to consume numeric status.get('/apis')→.get('/api')Related
Test plan
ci/prow/checkandci/prow/unit-tests-sonarcloudpass in prow