Skip to content

Fix memory leak in fleet autoscaler webhook HTTP client#4493

Merged
markmandel merged 2 commits intoagones-dev:mainfrom
markmandel:bug/webhook-client
Mar 31, 2026
Merged

Fix memory leak in fleet autoscaler webhook HTTP client#4493
markmandel merged 2 commits intoagones-dev:mainfrom
markmandel:bug/webhook-client

Conversation

@markmandel
Copy link
Copy Markdown
Collaborator

What type of PR is this?

Uncomment only one /kind <> line, press enter to put that in a new line, and remove leading whitespace from that line:

/kind breaking

/kind bug

/kind cleanup
/kind documentation
/kind feature
/kind hotfix
/kind release

What this PR does / Why we need it:

  • Change fasThread.state from fasState (value) to *fasState (pointer) so the cached http.Client persists across sync cycles instead of being recreated on every iteration.
  • Drain HTTP response body before closing to allow http.Transport to reuse connections, preventing unbounded connection growth.

Which issue(s) this PR fixes:

https://agones.slack.com/archives/C9DGM5DS8/p1774882327112899

Special notes for your reviewer:

Thanks @antiphp for the report!

@github-actions github-actions bot added the kind/bug These are bugs. label Mar 30, 2026
- Change fasThread.state from fasState (value) to *fasState (pointer) so
  the cached http.Client persists across sync cycles instead of being
  recreated on every iteration.
- Drain HTTP response body before closing to allow http.Transport to
  reuse connections, preventing unbounded connection growth.

Signed-off-by: Mark Mandel <mark@compoundtheory.com>
@agones-bot
Copy link
Copy Markdown
Collaborator

Build Failed 😭

Build Id: d67b1d54-7d4d-41e4-a176-283019a669a5

Status: FAILURE

To get permission to view the Cloud Build view, join the agones-discuss Google Group.

@markmandel
Copy link
Copy Markdown
Collaborator Author

VERBOSE: time="2026-03-30 20:55:24.798" level=info msg="checking if GameServer exists" error="<nil>" gs=game-server58jwh state=Ready test=TestGameServerPodCompletedAfterCleanExit
VERBOSE:     gameserver_test.go:549: 
VERBOSE:         	Error Trace:	/go/src/agones.dev/agones/test/e2e/gameserver_test.go:549
VERBOSE:         	Error:      	Received unexpected error:
VERBOSE:         	            	context deadline exceeded
VERBOSE:         	Test:       	TestGameServerPodCompletedAfterCleanExit
VERBOSE: --- FAIL: TestGameServerPodCompletedAfterCleanExit (303.20s)

Got a fix for this one in #4480 (least I think so)

/gcbrun

@agones-bot
Copy link
Copy Markdown
Collaborator

Build Succeeded 🥳

Build Id: a05add47-7a67-49ae-94f6-84bb1cafac75

The following development artifacts have been built, and will exist for the next 30 days:

A preview of the website (the last 30 builds are retained):

To install this version:

git fetch https://github.com/googleforgames/agones.git pull/4493/head:pr_4493 && git checkout pr_4493
helm install agones ./install/helm/agones --namespace agones-system --set agones.image.registry=us-docker.pkg.dev/agones-images/ci --set agones.image.tag=1.57.0-dev-bb349f5

Copy link
Copy Markdown
Collaborator

@lacroixthomas lacroixthomas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM ! Good catch !

@markmandel markmandel merged commit 7d7e224 into agones-dev:main Mar 31, 2026
4 checks passed
@markmandel markmandel deleted the bug/webhook-client branch March 31, 2026 16:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug These are bugs. size/S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants