fix: bound Allocate calls with the poll context in TestAllocatorAfter… #4742
Build Failed :sob:
_Build Id: 1ea696bf-9963-4000-a13e-bfcea07d3529_
Status: FAILURE
- Cloud Build view
- Cloud Build log download
To get permission to view the Cloud Build view, join the agones-discuss Google Group.
Build Failed :sob:
_Build Id: 7db040fe-390e-477d-a543-61385cc48400_
Status: FAILURE
- Cloud Build view
- Cloud Build log download
To get permission to view the Cloud Build view, join the agones-discuss Google Group.
/gcbrun
Build Failed :sob:
_Build Id: 804f1099-411a-4610-893a-df63aba03082_
Status: FAILURE
- Cloud Build view
- Cloud Build log download
To get permission to view the Cloud Build view, join the agones-discuss Google Group.
Build Succeeded :partying_face:
_Build Id: 845fb11d-3c75-4aec-a6dc-4e40a4032900_
The following development artifacts have been built, and will exist for the next 30 days:
image: us-docker.pkg.dev/agones-images/ci/agones-controller:1.61.0-dev-f188956
image: us-docker.pkg.dev/agones-images/ci/agones-extensions:1.61.0-dev-f188956
image: us-docker.pkg.dev/agones-images/ci/agones-sdk:1.61.0-dev-f188956-linux
image: us-docker.pkg.dev/agones-images/ci/agones-ping:1.61.0-dev-f188956
image: us-docker.pkg.dev/agones-images/ci/agones-allocator:1.61.0-dev-f188956
image: us-docker.pkg.dev/agones-images/ci/agones-processor:1.61.0-dev-f188956
Linux C++ SDK (build): agonessdk-1.61.0-dev-f188956-linux-arch_64.tar.gz
SDK Server: agonessdk-server-1.61.0-dev-f188956.zip
A preview of the website (the last 30 builds are retained):
To install this version:
git fetch https://github.com/googleforgames/agones.git pull/4742/head:pr_4742 && git checkout pr_4742
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.61.0-dev-f188956
Seems legit to me - any notes on why this solves this issue?
The return error from wait.PollUntilContextTimeout is discarded. This can lead to false positives: if the poll times out without reaching requiredConsecutiveSuccesses but the last Allocate happened to succeed, lastErr would be nil and the test could incorrectly pass. Capture the poll error and assert it is nil (e.g., pollErr := wait...; require.NoError(t, pollErr)), in addition to checking lastErr/lastResponse.
The poll callback ignores the context passed into the closure and instead derives callCtx from the outer ctx. PollUntilContextTimeout supplies a context that is canceled when the poll deadline is reached; deriving from that supplied context ensures Allocate calls stop promptly when the poll times out/cancels (and also inherits the earlier deadline). Consider changing the callback signature to accept pollCtx context.Context (instead of _) and derive callCtx from pollCtx.
Enabling client keepalives with PermitWithoutStream: true and a 10s ping interval can cause unintended load and can be rejected by some LBs/proxies/servers (e.g., leading to GOAWAY/connection churn) if their minimum keepalive policy is higher. If the goal is just to prevent idle disconnects in tests, consider either (a) increasing Time, (b) setting PermitWithoutStream to false so pings only occur with active RPCs, or (c) making these values configurable for different e2e environments.
[!WARNING]
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add acopilot-code-review.ymlfile specifying one with theruns-onattribute. See the docs for more details.
Pull request overview
This PR aims to reduce flakiness in the allocator e2e test around replica termination by bounding gRPC allocation calls and improving connection liveness behavior.
Changes:
TestAllocatorAfterDeleteReplica to use a per-Allocate timeout and require consecutive successful Allocate calls.Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
| ---- | ----------- |
| test/e2e/allochelper/helper_func.go | Adds gRPC keepalive client params to help keep allocator connections alive during e2e runs. |
| test/e2e/allocator/pod_termination_test.go | Refines polling/allocation loop with per-call timeouts and consecutive success criteria. |
---
💡 <a href="/agones-dev/agones/new/main?filename=.github/skills/code-review/SKILL.md" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Add a code-review agent skill</a> or configure MCP servers for context-aware, tailored reviews. <a href="https://docs.github.com/copilot/how-tos/use-copilot-agents/request-a-code-review/use-code-review?tool=webui#mcp-servers-and-agent-skills" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Learn more in the docs.</a>
🤔 not sure I 100% agree with this one. But might be worth considering using a require.EventuallyWithT () to ensure that error values get reported correctly.
Build Succeeded :partying_face:
_Build Id: 4f1ed99f-bc4a-4d0b-a436-0bb7c67fcf76_
The following development artifacts have been built, and will exist for the next 30 days:
image: us-docker.pkg.dev/agones-images/ci/agones-controller:1.61.0-dev-2c4fd28
image: us-docker.pkg.dev/agones-images/ci/agones-extensions:1.61.0-dev-2c4fd28
image: us-docker.pkg.dev/agones-images/ci/agones-sdk:1.61.0-dev-2c4fd28-linux
image: us-docker.pkg.dev/agones-images/ci/agones-ping:1.61.0-dev-2c4fd28
image: us-docker.pkg.dev/agones-images/ci/agones-allocator:1.61.0-dev-2c4fd28
image: us-docker.pkg.dev/agones-images/ci/agones-processor:1.61.0-dev-2c4fd28
Linux C++ SDK (build): agonessdk-1.61.0-dev-2c4fd28-linux-arch_64.tar.gz
SDK Server: agonessdk-server-1.61.0-dev-2c4fd28.zip
A preview of the website (the last 30 builds are retained):
To install this version:
git fetch https://github.com/googleforgames/agones.git pull/4742/head:pr_4742 && git checkout pr_4742
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.61.0-dev-2c4fd28
Build Succeeded :partying_face:
_Build Id: a86a64ae-59de-4268-9155-aadfc1962ad4_
The following development artifacts have been built, and will exist for the next 30 days:
image: us-docker.pkg.dev/agones-images/ci/agones-controller:1.62.0-dev-a509e1d
image: us-docker.pkg.dev/agones-images/ci/agones-extensions:1.62.0-dev-a509e1d
image: us-docker.pkg.dev/agones-images/ci/agones-sdk:1.62.0-dev-a509e1d-linux
image: us-docker.pkg.dev/agones-images/ci/agones-ping:1.62.0-dev-a509e1d
image: us-docker.pkg.dev/agones-images/ci/agones-allocator:1.62.0-dev-a509e1d
image: us-docker.pkg.dev/agones-images/ci/agones-processor:1.62.0-dev-a509e1d
Linux C++ SDK (build): agonessdk-1.62.0-dev-a509e1d-linux-arch_64.tar.gz
SDK Server: agonessdk-server-1.62.0-dev-a509e1d.zip
A preview of the website (the last 30 builds are retained):
To install this version:
git fetch https://github.com/googleforgames/agones.git pull/4742/head:pr_4742 && git checkout pr_4742
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.62.0-dev-a509e1d
This changes what the test checks. It was added with the draining work (#3839/#3843) to make sure Allocate keeps succeeding for the whole drain window after a replica is deleted ("keep making calls till we know the draining time has passed"), and to fail on any error.
With EventuallyWithT:
terminationGracePeriodSeconds is 333 = 27s, so we stop checking ~10s into the drain.successes = 0 just resets the count, so a regression that drops requests mid-drain can still pass.Could we keep the original structure and just add the deadline? Something like:
_ = wait.PollUntilContextTimeout(ctx, retryInterval, retryTimeout, true, func(pollCtx context.Context) (bool, error) {
callCtx, cancel := context.WithTimeout(pollCtx, allocateTimeout)
defer cancel()
response, err := grpcClient.Allocate(callCtx, request)
logger.Infof("err = %v (code = %v), response = %v", err, status.Code(err), response)
helper.ValidateAllocatorResponse(t, response)
require.NoError(t, err, "Failed grpc allocation request")
return false, nil
})
If we do want some tolerance, I'd limit it to codes.Unavailable/codes.DeadlineExceeded and still poll for the full drain window.
Minor: this now validates only the last response instead of every one.
Also, the default fleet only has replicasCount = 5 game servers. A call that times out on the client may still allocate on the server, so the effective retry budget is ~5 successful allocations regardless of retryTimeout. After that the test fails with a misleading "no available GameServer" error.
Nit: this constant is also used by the "wait for agones-allocator to stabilize" poll above, so it doubles that timeout too. Harmless, but worth knowing.
I'd drop this. The allocator server enforces KeepaliveEnforcementPolicy{MinTime: 1 * time.Minute} (cmd/allocator/main.go), while this client pings after 10s of idle with PermitWithoutStream: true. After a few pings that break that policy, grpc-go servers send GOAWAY with too_many_pings and close the connection, which churns connections and can fail calls in flight.
CreateRemoteClusterDialOptions is also shared by ~9 allocator e2e call sites, so this affects all of them. The per-call deadline already bounds the dead-connection case, so this shouldn't be needed for #4727.
Please fill in "What this PR does / Why we need it" and reply to @markmandel's question about why this fixes the issue.
The PR title ("bound Allocate calls with the poll context") no longer matches the code, which now uses the outer ctx.
Additional comments in-line.
Build Failed :sob:
_Build Id: 98850728-659d-467b-9ed4-c15bace0afc1_
Status: FAILURE
- Cloud Build view
- Cloud Build log download
To get permission to view the Cloud Build view, join the agones-discuss Google Group.
/gcbrun
Build Failed :sob:
_Build Id: 00ea8262-8db8-4a1d-80ed-5bdf87ee908b_
Status: FAILURE
- Cloud Build view
- Cloud Build log download
To get permission to view the Cloud Build view, join the agones-discuss Google Group.
/gcbrun
Build Failed :sob:
_Build Id: 76434b87-c8fc-4a7d-9a73-09c51f755b22_
Status: FAILURE
- Cloud Build view
- Cloud Build log download
To get permission to view the Cloud Build view, join the agones-discuss Google Group.
/gcbrun
Build Failed :sob:
_Build Id: fc77a014-e704-45b3-bed0-91d6812a7725_
Status: FAILURE
- Cloud Build view
- Cloud Build log download
To get permission to view the Cloud Build view, join the agones-discuss Google Group.
Build Failed :sob:
_Build Id: 88cbd424-0984-4dfa-811c-6bae8d06a5bc_
Status: FAILURE
- Cloud Build view
- Cloud Build log download
To get permission to view the Cloud Build view, join the agones-discuss Google Group.
/gcbrun
Build Failed :sob:
_Build Id: ed411788-090a-4a91-a11d-793f72b82046_
Status: FAILURE
- Cloud Build view
- Cloud Build log download
To get permission to view the Cloud Build view, join the agones-discuss Google Group.
/gcbrun
Build Failed :sob:
_Build Id: 55981400-ce9c-4627-b604-9547b64c1956_
Status: FAILURE
- Cloud Build view
- Cloud Build log download
To get permission to view the Cloud Build view, join the agones-discuss Google Group.
Build Failed :sob:
_Build Id: fc43596d-bfac-4560-a1cd-ea1986aab973_
Status: FAILURE
- Cloud Build view
- Cloud Build log download
To get permission to view the Cloud Build view, join the agones-discuss Google Group.
Build Succeeded :partying_face:
_Build Id: ab9f6b32-41de-4552-b555-7e2aedf29af0_
The following development artifacts have been built, and will exist for the next 30 days:
image: us-docker.pkg.dev/agones-images/ci/agones-controller:1.62.0-dev-1353f35
image: us-docker.pkg.dev/agones-images/ci/agones-extensions:1.62.0-dev-1353f35
image: us-docker.pkg.dev/agones-images/ci/agones-sdk:1.62.0-dev-1353f35-linux
image: us-docker.pkg.dev/agones-images/ci/agones-ping:1.62.0-dev-1353f35
image: us-docker.pkg.dev/agones-images/ci/agones-allocator:1.62.0-dev-1353f35
image: us-docker.pkg.dev/agones-images/ci/agones-processor:1.62.0-dev-1353f35
Linux C++ SDK (build): agonessdk-1.62.0-dev-1353f35-linux-arch_64.tar.gz
SDK Server: agonessdk-server-1.62.0-dev-1353f35.zip
A preview of the website (the last 30 builds are retained):
To install this version:
git fetch https://github.com/googleforgames/agones.git pull/4742/head:pr_4742 && git checkout pr_4742
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.62.0-dev-1353f35
markmandel
Sivasankaran25
…DeleteReplica
<!-- Thanks for sending a pull request! Here are some tips for you:
1. If this is your first time, please read our contributor guidelines: https://github.com/agones-dev/agones/blob/main/CONTRIBUTING.md and developer guide https://github.com/agones-dev/agones/blob/main/build/README.md
2. Please label this pull request according to what type of issue you are addressing.
3. Ensure you have added or ran the appropriate tests for your PR: https://github.com/agones-dev/agones/blob/main/build/README.md#testing-and-building
-->
What type of PR is this?
/kind bug
What this PR does / Why we need it:
Which issue(s) this PR fixes:
<!--
*Automatically closes linked issue when PR is merged.
Usage:
Closes #<issue number>, orCloses (paste link of issue).Use "Work on #<issue number>" if you wish to reference the issue without closing it.
-->
Closes #4727
Did you use AI tools in preparing this PR?:
<!--
If you used AI tools in preparing your PR, you must disclose this in the description of your PR.
--->
Y
Special notes for your reviewer: