Skip to content

Feat: integrate batch allocator in processor allocator#4559

Open
lacroixthomas wants to merge 9 commits into
agones-dev:mainfrom
lacroixthomas:features/add-batch-allocator-in-processor-allocator
Open

Feat: integrate batch allocator in processor allocator#4559
lacroixthomas wants to merge 9 commits into
agones-dev:mainfrom
lacroixthomas:features/add-batch-allocator-in-processor-allocator

Conversation

@lacroixthomas

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 feature

What this PR does / Why we need it:

Bring the batch allocator improvement from this PR to the processorAllocator feature gate : #4176

Which issue(s) this PR fixes:

Part of #4190 and #3992

Special notes for your reviewer:

@github-actions github-actions Bot added kind/feature New features for Agones size/L labels May 10, 2026
@agones-bot

Copy link
Copy Markdown
Collaborator

Build Failed 😭

Build Id: c114e430-ff0d-4839-957e-5fd66102b7b0

Status: FAILURE

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

@github-actions

Copy link
Copy Markdown

This PR exceeds the recommended size of 1000 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size.

1 similar comment
@github-actions

Copy link
Copy Markdown

This PR exceeds the recommended size of 1000 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size.

@lacroixthomas

Copy link
Copy Markdown
Collaborator Author

This is quite a "direct" import of the changes from the original PR, did minor updates on it
Will come back to it to ensure everything is fine in the code itself (might have seen some part that could be updated - improved) and also manually testing it with it all (actual allocations flow etc.)

@agones-bot

Copy link
Copy Markdown
Collaborator

Build Failed 😭

Build Id: c50b1a31-0600-48c2-95e8-4face7902b8e

Status: FAILURE

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

@lacroixthomas

Copy link
Copy Markdown
Collaborator Author

/gcbrun

@agones-bot

Copy link
Copy Markdown
Collaborator

Build Failed 😭

Build Id: 4246cd2b-53d1-4624-98df-3b0ca5e6fb97

Status: FAILURE

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

@lacroixthomas

Copy link
Copy Markdown
Collaborator Author

/gcbrun

Step #1 - "e2e-feature-gates": Release "agones" does not exist. Installing it now.
Step #1 - "e2e-feature-gates": I0512 16:40:40.497273      90 warnings.go:110] "Warning: autopilot-default-resources-mutator:Autopilot updated Deployment agones-system/agones-ping: defaulted unspecified 'cpu' resource for containers [agones-ping] (see http://g.co/gke/autopilot-defaults)."
Step #1 - "e2e-feature-gates": I0512 16:40:40.550869      90 warnings.go:110] "Warning: autopilot-default-resources-mutator:Autopilot updated Deployment agones-system/agones-extensions: defaulted unspecified 'cpu' resource for containers [agones-extensions] (see http://g.co/gke/autopilot-defaults)."
Step #1 - "e2e-feature-gates": I0512 16:40:40.550922      90 warnings.go:110] "Warning: autopilot-default-resources-mutator:Autopilot updated Deployment agones-system/agones-controller: defaulted unspecified 'cpu' resource for containers [agones-controller] (see http://g.co/gke/autopilot-defaults)."
Step #1 - "e2e-feature-gates": I0512 16:40:40.587701      90 warnings.go:110] "Warning: autopilot-default-resources-mutator:Autopilot updated Deployment agones-system/agones-allocator: defaulted unspecified 'cpu' resource for containers [agones-allocator] (see http://g.co/gke/autopilot-defaults)."
Step #1 - "e2e-feature-gates": I0512 16:40:40.828318      90 warnings.go:110] "Warning: AdmissionWebhookController: mutated namespaceselector of the webhooks to enforce GKE Autopilot policies."
Step #1 - "e2e-feature-gates": I0512 16:40:40.867417      90 warnings.go:110] "Warning: AdmissionWebhookController: mutated namespaceselector of the webhooks to enforce GKE Autopilot policies."
Step #1 - "e2e-feature-gates": I0512 16:50:45.051070      90 warnings.go:110] "Warning: autopilot-default-resources-mutator:Autopilot updated Job agones-system/agones-delete-agones-resources: defaulted unspecified 'cpu' resource for containers [pre-delete-delete-agones-resources] (see http://g.co/gke/autopilot-defaults)."
Step #1 - "e2e-feature-gates": Error: release agones failed, and has been uninstalled due to atomic being set: context deadline exceeded
Step #1 - "e2e-feature-gates": make: *** [Makefile:446: install] Error 1

@agones-bot

Copy link
Copy Markdown
Collaborator

Build Succeeded 🥳

Build Id: ff1ca275-3f67-4710-8594-a3dcf6bd472f

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/4559/head:pr_4559 && git checkout pr_4559
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.58.0-dev-32c71b9

@miai10 miai10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good

Comment thread pkg/gameserverallocations/allocator.go Outdated
@github-actions

Copy link
Copy Markdown

This PR exceeds the recommended size of 1000 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size.

@agones-bot

Copy link
Copy Markdown
Collaborator

Build Failed 😭

Build Id: 68ed4e65-1fa3-402d-8035-3e561058d925

Status: FAILURE

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

@github-actions

Copy link
Copy Markdown

This PR exceeds the recommended size of 1000 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size.

@agones-bot

Copy link
Copy Markdown
Collaborator

Build Failed 😭

Build Id: d8e3da64-c889-4a5f-a488-91c6d963bd23

Status: FAILURE

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

@miai10

miai10 commented May 31, 2026

Copy link
Copy Markdown
Contributor

LGTM!

@github-actions

Copy link
Copy Markdown

This PR exceeds the recommended size of 1000 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size.

@agones-bot

Copy link
Copy Markdown
Collaborator

Build Succeeded 🥳

Build Id: 49b84f77-5e45-46f3-b9bf-5e7a10dc66a9

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/4559/head:pr_4559 && git checkout pr_4559
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-391e820

@github-actions

Copy link
Copy Markdown

This PR exceeds the recommended size of 1000 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size.

@agones-bot

Copy link
Copy Markdown
Collaborator

Build Succeeded 🥳

Build Id: 551a05f8-1a19-4098-9389-1bd9d8fad35f

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/4559/head:pr_4559 && git checkout pr_4559
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-fd67e32

lacroixthomas and others added 4 commits July 7, 2026 17:17
Signed-off-by: Thomas Lacroix <thomas.lacroix@epitech.eu>
Signed-off-by: Thomas Lacroix <thomas.lacroix@epitech.eu>
Signed-off-by: Thomas Lacroix <thomas.lacroix@epitech.eu>
Signed-off-by: Thomas Lacroix <thomas.lacroix@epitech.eu>
@lacroixthomas
lacroixthomas force-pushed the features/add-batch-allocator-in-processor-allocator branch from fd67e32 to 8bf3c39 Compare July 7, 2026 21:17
@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown

This PR exceeds the recommended size of 1000 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size.

@agones-bot

Copy link
Copy Markdown
Collaborator

Build Failed 😭

Build Id: d52a066c-5aed-45fc-a35e-f207dca8a47b

Status: FAILURE

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

Signed-off-by: Thomas Lacroix <thomas.lacroix@epitech.eu>
@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown

This PR exceeds the recommended size of 1000 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size.

@agones-bot

Copy link
Copy Markdown
Collaborator

Build Failed 😭

Build Id: 2f1cd500-b351-4a80-88f2-a0963b5a53c1

Status: FAILURE

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

@lacroixthomas

Copy link
Copy Markdown
Collaborator Author

/gcbrun

Signed-off-by: Thomas Lacroix <thomas.lacroix@epitech.eu>
@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown

This PR exceeds the recommended size of 1000 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size.

@agones-bot

Copy link
Copy Markdown
Collaborator

Build Failed 😭

Build Id: ecd49a81-249e-42c3-a66e-3c2319bcea12

Status: FAILURE

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

Signed-off-by: Thomas Lacroix <thomas.lacroix@epitech.eu>
@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown

This PR exceeds the recommended size of 1000 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size.

@agones-bot

Copy link
Copy Markdown
Collaborator

Build Failed 😭

Build Id: d246536c-b23a-42fd-9e92-9d61c8e4526e

Status: FAILURE

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

Signed-off-by: Thomas Lacroix <thomas.lacroix@epitech.eu>
@github-actions

github-actions Bot commented Jul 7, 2026

Copy link
Copy Markdown

This PR exceeds the recommended size of 1000 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size.

@lacroixthomas
lacroixthomas marked this pull request as ready for review July 7, 2026 23:19
@agones-bot

Copy link
Copy Markdown
Collaborator

Build Failed 😭

Build Id: 2ae33ff8-fe72-4e3a-9939-6547fd1434a1

Status: FAILURE

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

@lacroixthomas

Copy link
Copy Markdown
Collaborator Author

/gcbrun

@agones-bot

Copy link
Copy Markdown
Collaborator

Build Succeeded 🥳

Build Id: a7f42097-7e72-41fa-976a-0608c252904d

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/4559/head:pr_4559 && git checkout pr_4559
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.60.0-dev-1964895

@lacroixthomas
lacroixthomas requested a review from a team July 9, 2026 20:52
@github-actions

Copy link
Copy Markdown

This PR exceeds the recommended size of 1000 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size.

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

Some thoughts for you!

c.allocationCache.AddGameServer(gs)
}
res.err = ErrGameServerUpdateConflict
res.err = goErrors.Join(ErrGameServerUpdateConflict, err)

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.

golang native error management is slipping through.

Might be time to really commit to #4510

if applyErr == nil {
if alreadyAllocated {
existingBatch.responses = append(existingBatch.responses, response{request: req, gs: gsToReorder.DeepCopy(), err: nil})
existingBatch.counterErrors = goErrors.Join(existingBatch.counterErrors, counterErrors)

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.

More native go error handling slipping though.

var propagatedErr error
updatedGs, updateErr := c.gameServerGetter.GameServers(lastGsState.ObjectMeta.Namespace).Update(ctx, lastGsState, metav1.UpdateOptions{})
if updateErr != nil {
c.allocationCache.AddGameServer(lastGsState)

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.

If the erorr is a conflict, we shouldn't put it back in the cache, as the data will be stale.

case goErrors.Is(err, ErrConflictInGameServerSelection):
gsa.Status.State = allocationv1.GameServerAllocationContention
return gsa, nil
case goErrors.Is(err, ErrGameServerUpdateConflict):

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.

More modern go error library slipping through.

updatedGs, updateErr := c.gameServerGetter.GameServers(lastGsState.ObjectMeta.Namespace).Update(ctx, lastGsState, metav1.UpdateOptions{})
if updateErr != nil {
c.allocationCache.AddGameServer(lastGsState)
propagatedErr = goErrors.Join(ErrGameServerUpdateConflict, updateErr)

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.

Shouldn't this only be a Conflict error, on an actual conflict?

}

case <-ctx.Done():
flush()

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.

Not sure I understand why we're flushing when we are shutting down -- would this lock up, as it's pushing into channels that don't have any workers to receive?

switch {
case err == nil:
return true, nil
case err == ErrNoGameServer:

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.

Should this be removed?

gsToReorderIndex int
want []*agonesv1.GameServer
}{
"pakced (no change)": {

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.

packed 😄

return

default:
flush()

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.

Nit: flush will recreate a new map on each pass through - even when there's nothing to process. Would be good to check this either inside or outside of flush()

if removeErr := c.allocationCache.RemoveGameServer(foundGs); removeErr != nil {
removeErr = errors.Wrap(removeErr, "error removing gameserver from cache")
req.response <- response{request: req, gs: nil, err: removeErr}
list = append(list[:foundGsIndex], list[foundGsIndex+1:]...)

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.

If this fails, is the index now wrong? since the list has changed size?

@agones-bot

Copy link
Copy Markdown
Collaborator

Build Succeeded 🥳

Build Id: dee469f2-222e-4a45-b738-6b1541fbf89f

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/4559/head:pr_4559 && git checkout pr_4559
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.60.0-dev-8ef34ef

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/feature New features for Agones size/L size/XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants