Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix: Fix flapping with list-based FleetAutoscaler#4625

Merged
markmandel merged 2 commits into
agones-dev:mainfrom
rhysperry111:fix/fleetautoscaler-list-flapping
Jun 23, 2026
Merged

fix: Fix flapping with list-based FleetAutoscaler#4625
markmandel merged 2 commits into
agones-dev:mainfrom
rhysperry111:fix/fleetautoscaler-list-flapping

Conversation

@rhysperry111

@rhysperry111 rhysperry111 commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

What type of PR is this?

/kind bug

What this PR does / Why we need it:

There is an issue caused by inconsistencies in FleetAutoscaler upscale logic and downscale logic, resulting in flapping when using a List based policy. This was reported here on Slack.


The root cause of the problem is due to the way that downscale decisions are made. The downscale logic:

  1. Gets the list of current GameServers
  2. Simulates a deletion
  3. Checks whether doing such would cause a server to need to be added again according to the list policy

The first two steps were implemented in a way that does not match how Fleets will actually choose to delete a server, as it doesn't exclude GameServers that would normally be considered undeletable. This inconsistency between the simulated deletion and actual deletion logic is what leads to constant upscaling and downscaling (flapping).


The first commit on this PR implements a test to reproduce the issue described, and to help check for regressions in the future.

The second commit on the PR implements the logic in FleetAutoscaler to correctly check which servers would be deleted on a downscale.

Which issue(s) this PR fixes:

Addresses the issue raised on Slack here.

Did you use AI tools in preparing this PR?:

No

Special notes for your reviewer:

A build of this code was tested by the user that originally reported the issue on Slack. They are able to confirm that it fixes the original issue.

@github-actions github-actions Bot added kind/bug These are bugs. size/M labels Jun 18, 2026
@rhysperry111 rhysperry111 force-pushed the fix/fleetautoscaler-list-flapping branch 2 times, most recently from d6a0d4d to 54051dd Compare June 18, 2026 16:31
@markmandel

Copy link
Copy Markdown
Member

/gcbrun

Let's run it!

@agones-bot

Copy link
Copy Markdown
Collaborator

Build Succeeded 🥳

Build Id: dba2d045-e0fb-411c-80bf-d65f08fb8fde

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/4625/head:pr_4625 && git checkout pr_4625
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.59.0-dev-54051dd

@rhysperry111 rhysperry111 marked this pull request as ready for review June 18, 2026 20:05
Comment thread pkg/fleetautoscalers/fleetautoscalers.go Outdated
@rhysperry111 rhysperry111 force-pushed the fix/fleetautoscaler-list-flapping branch 3 times, most recently from 7689469 to f4f142d Compare June 19, 2026 21:37
@markmandel

Copy link
Copy Markdown
Member

/gcbrun

@agones-bot

Copy link
Copy Markdown
Collaborator

Build Failed 😭

Build Id: 25f74ba2-9d6d-4ce8-8b13-722ed7a854e3

Status: FAILURE

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

@rhysperry111

Copy link
Copy Markdown
Contributor Author

It passed yesterday and all that's changed since is a rebase and a comment 😭

@markmandel

Copy link
Copy Markdown
Member

/gcbrun

That's a new flake - haven't seen that before. Let's run it again, while I run this in the background.

@agones-bot

Copy link
Copy Markdown
Collaborator

Build Succeeded 🥳

Build Id: 4e13082e-de99-44a5-ab21-40bf3e84d636

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/4625/head:pr_4625 && git checkout pr_4625
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.59.0-dev-f4f142d

@lacroixthomas lacroixthomas left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@markmandel markmandel left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Found a couple of small things - but otherwise, LGTM.

Comment thread pkg/fleetautoscalers/fleetautoscalers_test.go
Comment thread pkg/fleetautoscalers/fleetautoscalers_test.go Outdated
Comment thread pkg/fleetautoscalers/fleetautoscalers_test.go Outdated
@rhysperry111 rhysperry111 force-pushed the fix/fleetautoscaler-list-flapping branch from ca6e052 to 5cbf6d1 Compare June 23, 2026 18:11
@rhysperry111

rhysperry111 commented Jun 23, 2026

Copy link
Copy Markdown
Contributor Author

Reworked the tests to be a bit more data-driven (with some test cases that also hit the limited paths). Also covers asserting the limited response. Thanks Mark and Thomas for the pointers :D

@rhysperry111 rhysperry111 requested a review from markmandel June 23, 2026 18:13
@markmandel markmandel enabled auto-merge (squash) June 23, 2026 18:22
@markmandel

Copy link
Copy Markdown
Member

/gcbrun

@agones-bot

Copy link
Copy Markdown
Collaborator

Build Failed 😭

Build Id: 1fc4aa37-0b38-445a-a757-60505f6aa9f2

Status: FAILURE

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

@markmandel

Copy link
Copy Markdown
Member

/gcbrun

@agones-bot

Copy link
Copy Markdown
Collaborator

Build Succeeded 🥳

Build Id: 51d5bc32-aa28-4464-afbe-8f6c998ebd63

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/4625/head:pr_4625 && git checkout pr_4625
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.59.0-dev-5cbf6d1

@markmandel markmandel merged commit d1bec35 into agones-dev:main Jun 23, 2026
4 checks passed
@rhysperry111

Copy link
Copy Markdown
Contributor Author

Yippee!

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/M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants