-
Notifications
You must be signed in to change notification settings - Fork 819
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Buffer Unity SDK ReceiveData when watching for configuration changes #3872
Conversation
Build Failed 😱 Build Id: 08aff5a3-b399-4b8a-a663-afc47702c3e2 To get permission to view the Cloud Build view, join the agones-discuss Google Group. |
Build Succeeded 👏 Build Id: f6944bf4-da12-4fb9-a029-b13ddc15ba78 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:
|
Do you have someone on your team that can help out with reviewing this code? Our regular maintainers aren't as familiar with the Unity SDK. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to have at least a unit test for this. Although I'm not seeing any tests for the Unity SDK, which is... odd.
string fullLine = bufferString.Substring(0, newlineIndex); | ||
try | ||
{ | ||
var dictionary = (Dictionary<string, object>) Json.Deserialize(fullLine); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does the input look like for this method? Is all the data expected to be on one line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fullLine should always be a single JSON message on a single line. grpc-gateway turns streams into newline delineated JSON messages and JSON encoding will escape any newlines in the data, so the only newlines we encounter will be the ones intentionally sent to break full JSON messages.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving with the caveat that I don't have a way of testing this. LGTM per Liam Lutton and Jack Schaffner.
Build Succeeded 👏 Build Id: f9c2587b-c77c-4efd-90c9-36c9f9db72da 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:
|
This PR contains the following updates: | Package | Update | Change | |---|---|---| | [agones](https://agones.dev) ([source](https://github.com/googleforgames/agones)) | minor | `1.41.0` -> `1.42.0` | --- > [!WARNING] > Some dependencies could not be looked up. Check the Dependency Dashboard for more information. --- ### Release Notes <details> <summary>googleforgames/agones (agones)</summary> ### [`v1.42.0`](https://github.com/googleforgames/agones/blob/HEAD/CHANGELOG.md#v1420-2024-07-16) [Compare Source](https://github.com/googleforgames/agones/compare/v1.41.0...v1.42.0) [Full Changelog](https://github.com/googleforgames/agones/compare/v1.41.0...v1.42.0) **Breaking changes:** - Update csharp.md to indicate ConnectAsync is deprecated by [@​aallbrig](https://github.com/aallbrig) in [https://github.com/googleforgames/agones/pull/3866](https://github.com/googleforgames/agones/pull/3866) **Implemented enhancements:** - Add security context to Agones containers by [@​peterzhongyi](https://github.com/peterzhongyi) in [https://github.com/googleforgames/agones/pull/3856](https://github.com/googleforgames/agones/pull/3856) - Add Security Context to game server sidecar by [@​peterzhongyi](https://github.com/peterzhongyi) in [https://github.com/googleforgames/agones/pull/3869](https://github.com/googleforgames/agones/pull/3869) - Drop CountsAndLists Data from the Fleet and Game Server Set When the Flag is False by [@​igooch](https://github.com/igooch) in [https://github.com/googleforgames/agones/pull/3881](https://github.com/googleforgames/agones/pull/3881) - Adds tests to confirm that Fleet, Fleet Autoscaler, and Fleet Allocation apply defaults code is idempotent by [@​igooch](https://github.com/igooch) in [https://github.com/googleforgames/agones/pull/3888](https://github.com/googleforgames/agones/pull/3888) - feat: Add CRD Changes and Feature Flag for chain policy by [@​indexjoseph](https://github.com/indexjoseph) in [https://github.com/googleforgames/agones/pull/3880](https://github.com/googleforgames/agones/pull/3880) **Fixed bugs:** - sdk-server expects SDK_LOG_LEVEL by [@​KAllan357](https://github.com/KAllan357) in [https://github.com/googleforgames/agones/pull/3858](https://github.com/googleforgames/agones/pull/3858) - this will resolve From/layer extraction issue on ltsc2019 in examples by [@​ashutosji](https://github.com/ashutosji) in [https://github.com/googleforgames/agones/pull/3873](https://github.com/googleforgames/agones/pull/3873) - featuregate: adds validation if PortPolicyNone is not enabled by [@​daniellee](https://github.com/daniellee) in [https://github.com/googleforgames/agones/pull/3871](https://github.com/googleforgames/agones/pull/3871) - added local as default for registry when registry is not specified by [@​kamaljeeti](https://github.com/kamaljeeti) in [https://github.com/googleforgames/agones/pull/3876](https://github.com/googleforgames/agones/pull/3876) - Buffer Unity SDK ReceiveData when watching for configuration changes by [@​ZeroParticle](https://github.com/ZeroParticle) in [https://github.com/googleforgames/agones/pull/3872](https://github.com/googleforgames/agones/pull/3872) - agones-{extensions,allocator}: Make servers context aware by [@​zmerlynn](https://github.com/zmerlynn) in [https://github.com/googleforgames/agones/pull/3845](https://github.com/googleforgames/agones/pull/3845) - added condition for distributed logic by [@​ashutosji](https://github.com/ashutosji) in [https://github.com/googleforgames/agones/pull/3877](https://github.com/googleforgames/agones/pull/3877) **Security fixes:** - Bump [@​grpc/grpc-js](https://github.com/grpc/grpc-js) from 1.10.7 to 1.10.9 in /sdks/nodejs by [@​dependabot](https://github.com/dependabot) in [https://github.com/googleforgames/agones/pull/3863](https://github.com/googleforgames/agones/pull/3863) **Other:** - Preparation for Release v1.42.0 by [@​ashutosji](https://github.com/ashutosji) in [https://github.com/googleforgames/agones/pull/3854](https://github.com/googleforgames/agones/pull/3854) - Add helpful note to edit-first-gameserver-go by [@​peterzhongyi](https://github.com/peterzhongyi) in [https://github.com/googleforgames/agones/pull/3846](https://github.com/googleforgames/agones/pull/3846) - Moved Passthrough feature description to the correct section in Feature Stages by [@​vicentefb](https://github.com/vicentefb) in [https://github.com/googleforgames/agones/pull/3861](https://github.com/googleforgames/agones/pull/3861) - Updated Node.js Page to Reflect that Counters and Lists is Implemented by [@​ashutosji](https://github.com/ashutosji) in [https://github.com/googleforgames/agones/pull/3865](https://github.com/googleforgames/agones/pull/3865) - Change Slack channel description from #developers to #development by [@​branhoff](https://github.com/branhoff) in [https://github.com/googleforgames/agones/pull/3868](https://github.com/googleforgames/agones/pull/3868) - updated UpdateList documentation for local sdk server and sdk server by [@​ashutosji](https://github.com/ashutosji) in [https://github.com/googleforgames/agones/pull/3878](https://github.com/googleforgames/agones/pull/3878) - Add zio-agones to the list of third party client SDKs by [@​ghostdogpr](https://github.com/ghostdogpr) in [https://github.com/googleforgames/agones/pull/3875](https://github.com/googleforgames/agones/pull/3875) - refactor simple game server by [@​ashutosji](https://github.com/ashutosji) in [https://github.com/googleforgames/agones/pull/3817](https://github.com/googleforgames/agones/pull/3817) - Update Slack invite link by [@​markmandel](https://github.com/markmandel) in [https://github.com/googleforgames/agones/pull/3896](https://github.com/googleforgames/agones/pull/3896) - Added cleanup for app-engine services in cloudbuild script by [@​kamaljeeti](https://github.com/kamaljeeti) in [https://github.com/googleforgames/agones/pull/3890](https://github.com/googleforgames/agones/pull/3890) - Adds a command to generate the zz_generated.deepcopy.go files for the apis by [@​igooch](https://github.com/igooch) in [https://github.com/googleforgames/agones/pull/3900](https://github.com/googleforgames/agones/pull/3900) - update go version to 1.21.12 by [@​ashutosji](https://github.com/ashutosji) in [https://github.com/googleforgames/agones/pull/3894](https://github.com/googleforgames/agones/pull/3894) **New Contributors:** - [@​KAllan357](https://github.com/KAllan357) made their first contribution in [https://github.com/googleforgames/agones/pull/3858](https://github.com/googleforgames/agones/pull/3858) - [@​branhoff](https://github.com/branhoff) made their first contribution in [https://github.com/googleforgames/agones/pull/3868](https://github.com/googleforgames/agones/pull/3868) - [@​aallbrig](https://github.com/aallbrig) made their first contribution in [https://github.com/googleforgames/agones/pull/3866](https://github.com/googleforgames/agones/pull/3866) - [@​ZeroParticle](https://github.com/ZeroParticle) made their first contribution in [https://github.com/googleforgames/agones/pull/3872](https://github.com/googleforgames/agones/pull/3872) - [@​ghostdogpr](https://github.com/ghostdogpr) made their first contribution in [https://github.com/googleforgames/agones/pull/3875](https://github.com/googleforgames/agones/pull/3875) </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40MzIuMCIsInVwZGF0ZWRJblZlciI6IjM3LjQzMi4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJyZW5vdmF0ZS9oZWxtIiwidHlwZS9taW5vciJdfQ==-->
What type of PR is this?
/kind bug
What this PR does / Why we need it:
Currently the Unity SDK watches for changes to the GameServer configuration by processing incoming data using
ReceiveData
onDownloadHandlerScript
. This function is not guaranteed to be passed a single, complete message, so it is possible for the JSON parse to fail. Though extremely rare, I have run into this problem a few times while doing load tests.Which issue(s) this PR fixes:
No associated issue, but I can open one if needed.
Special notes for your reviewer:
The Kubernetes JS client does something similar to this using the
byline
package: https://github.com/kubernetes-client/javascript/blob/master/src/watch.ts#L116In my testing it appears that creating messages based on newline characters is enough, so I implemented only that case.
Additional documentation on the Unity ReceiveData function: https://docs.unity3d.com/2021.3/Documentation/ScriptReference/Networking.DownloadHandler.ReceiveData.html