Skip to content

Fix update counter to return correct values#4324

Merged
igooch merged 9 commits intoagones-dev:mainfrom
indurireddy-TF:updateCounter
Nov 12, 2025
Merged

Fix update counter to return correct values#4324
igooch merged 9 commits intoagones-dev:mainfrom
indurireddy-TF:updateCounter

Conversation

@indurireddy-TF
Copy link
Copy Markdown
Collaborator

@indurireddy-TF indurireddy-TF commented Nov 4, 2025

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:

Which issue(s) this PR fixes:

Closes #4220

Special notes for your reviewer:

@agones-bot
Copy link
Copy Markdown
Collaborator

Build Succeeded 🥳

Build Id: adeda24c-8a2b-42a2-be8d-4c7d6560f7fd

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/4324/head:pr_4324 && git checkout pr_4324
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.54.0-dev-5cad379

@aditya-shantanu
Copy link
Copy Markdown

Add a test that validates this change ?

@indurireddy-TF
Copy link
Copy Markdown
Collaborator Author

Add a test that validates this change ?

Hi @aditya-shantanu I added a new test case to verify the changes.

CountDiff: 15,
}},
},
want: agonesv1.CounterStatus{Count: int64(25), Capacity: int64(100)},
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

nit: Change this to something other than the value before it so you are sure it got updated.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Updated CountDiff to 7. The initial counter value remains 10, consistent with existing test cases.

@agones-bot
Copy link
Copy Markdown
Collaborator

Build Succeeded 🥳

Build Id: e566ba42-3582-488a-a274-d570bd21a3d5

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/4324/head:pr_4324 && git checkout pr_4324
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.54.0-dev-927f04f

@agones-bot
Copy link
Copy Markdown
Collaborator

Build Succeeded 🥳

Build Id: 1586d105-bb6a-4b29-8f16-c3881fb4c0cb

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/4324/head:pr_4324 && git checkout pr_4324
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.54.0-dev-d057c0c

@markmandel
Copy link
Copy Markdown
Collaborator

Thanks for this! I would like to take this for a spin when integrated with our simple gameserver container we use for e2e testing.

We don't have a great way of automating testing this, so it may need to be manual 🙃

Copy link
Copy Markdown
Collaborator

@markmandel markmandel left a comment

Choose a reason for hiding this comment

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

Don't actually need to test this with simple-game-server now I look at this code - just have one more follow up question. 👍🏻

@markmandel markmandel requested a review from Copilot November 10, 2025 15:20
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR updates the UpdateCounter method to return the projected counter state instead of an empty beta.Counter{} object. This allows SDK clients to immediately see the expected state after their update request without needing to make a separate GetCounter call.

Key Changes:

  • Modified UpdateCounter to return projected counter state via new projectCounterState helper function
  • Added test case "projected state returned" to verify the returned projected state matches expected values
  • Test validates that a counter update with CountDiff: 7 correctly returns projected Count: 17

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
pkg/sdkserver/sdkserver.go Added projectCounterState function to calculate projected counter state and updated UpdateCounter to return projected state instead of empty Counter
pkg/sdkserver/sdkserver_test.go Added "starfish" counter fixture and "projected state returned" test case to validate UpdateCounter returns correct projected state

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@indurireddy-TF indurireddy-TF requested review from igooch and removed request for Sivasankaran25 November 10, 2025 18:30
@agones-bot
Copy link
Copy Markdown
Collaborator

Build Succeeded 🥳

Build Id: 0eec7b90-5683-45d8-85c3-8714eb95edab

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/4324/head:pr_4324 && git checkout pr_4324
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.54.0-dev-bf808b1

@markmandel markmandel requested a review from Copilot November 10, 2025 19:26
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@markmandel
Copy link
Copy Markdown
Collaborator

I think this is good to go. @igooch did you want to do another review?

Copy link
Copy Markdown
Collaborator

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

@igooch igooch enabled auto-merge (squash) November 12, 2025 00:51
@agones-bot
Copy link
Copy Markdown
Collaborator

Build Failed 😭

Build Id: 56b57b3f-07df-4e45-98f1-139e872f2fb5

Status: FAILURE

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

@Sivasankaran25
Copy link
Copy Markdown
Collaborator

/gcbrun

@agones-bot
Copy link
Copy Markdown
Collaborator

Build Succeeded 🥳

Build Id: 2a7ede8e-656c-4ed2-920a-1c9c59b32b48

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/4324/head:pr_4324 && git checkout pr_4324
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.54.0-dev-dffcebd

@igooch igooch merged commit 56b56bb into agones-dev:main Nov 12, 2025
4 checks passed
mnthe pushed a commit to mnthe/agones that referenced this pull request Mar 23, 2026
* Fix update counter to return correct values

* added testcase

* updated test value

* updated tests

---------

Co-authored-by: Sivasankaran R <sivasankaranr@google.com>
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.

Rest UpdateCounter not returning correct values

7 participants