-
Notifications
You must be signed in to change notification settings - Fork 830
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
Nodejs counters and lists #3726
Conversation
Build Failed 😱 Build Id: cd4e2795-51eb-4952-82ad-43e4d70abc71 To get permission to view the Cloud Build view, join the agones-discuss Google Group. |
It is a bit difficult to work with the CounterUpdateRequest in JavaScript due to the type google.protobuf.Int64Value instead of int64 From alpha.protoc
I got it working with the following but this seems like an internal type. It's a bit hacky to require/import at a nested path because it is not a supported export of the library, so will break if the library gets refactored#
I'm wondering why we don't use int64 instead as we use this in other places in the SDK (edited) |
@igooch Would you be able to shed any light on this? |
The google.protobuf.Int64Value is there so that it will be a nullable object rather than a primitive type that has a default value (0 in the case of Golang). In the case of updating the Count or Capacity 0 is a meaningful value, so we don't want 0 to be the default. 0 for the "diff" isn't meaningful, since that's just adding the diff to the Count. |
Thank you. Reading around, it also seems that For my curiosity I was wondering if we could use a wrapper type e.g. the
Also did we consider using -1 as a special value for count and capacity in the update to mean unspecified, as these would be invalid values? I don't know if these could be set by default to -1, so not setting them would leave them at -1. |
So we use these standard wrappers all over the place - I asked the gRPC team what the canonical way to import the standard wrappers is and will get back to you. |
Feedback I got was basically "if So I think we should move forward with this approach 👍🏻 |
Thank you and so it seems the library is missing some code as we should be able to do the following so a library user does not need to know the internal path
Or in the more modern format
But yes, can go ahead with the current solution |
That's a new one
You can ignore that. Restarting test. |
Build Failed 😱 Build Id: 14d2f577-ac55-42ea-a735-4d181de07309 To get permission to view the Cloud Build view, join the agones-discuss Google Group. |
Oooh, you will need to rebase against |
@steven-supersolid we're updating the SDK, so that most of the methods that return (bool, error) are now simply returning (error). I updated the issue #3645. (Discussion: #3581#discussion_r1505135182). Also tracked in #3737. |
Great, I think that is closer to the rest of the API. Will update |
@steven-supersolid we moved Counts and Lists from Alpha to Beta #3806. This is the last major expected change (until it goes into stable, but I imagine that will be several more releases away). |
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. |
Build Failed 😱 Build Id: 2e4fb29a-2a11-4ea5-885b-8479cb907465 To get permission to view the Cloud Build view, join the agones-discuss Google Group. |
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. |
Build Succeeded 👏 Build Id: 505e54a6-c93d-48d0-9f55-b4ec3f4acf36 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:
|
@igooch this should now be ready |
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.
A caveat that I'm not familiar with nodejs, so if you know of someone with more language specific knowledge that might have more insight, feel free to tag them in the comments.
Overall looks good, just a few clarifying comments.
Some of the language SDKs have unit tests. Do you think this would be beneficial to add, or would it not add anything beyond what's already being tested in test/sdk/nodejs/testSDKClient.js?
// LocalSDKServer starting "rooms": {Count: 1, Capacity: 10} | ||
const counter = "rooms"; | ||
|
||
try { |
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.
Genuine question here as I'm not familiar with nodejs, is there an advantage to using a try catch block over an assert statement like https://nodejs.org/api/assert.html#assertdoesnotrejectasyncfn-error-message?
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.
I've not used the Assert class much because it is usual to rely on a test runner framework such as jasmine or mocha instead.
In runtime code it is standard to rely on try/catch when dealing with async functions. In test code it is convenient to do the same.
I think in this case as we want to also check the return value it is easier to write the code with try/catch. We end up nesting in a try/catch block vs. nesting in a function call, which is preferable.
It may be worth investigating in another PR and also investigate if we could swap out jasmine for the new node.js built in test runner, which relies on assert.
@@ -165,7 +165,8 @@ run-sdk-conformance-test-cpp: | |||
$(MAKE) run-sdk-conformance-test SDK_FOLDER=cpp GRPC_PORT=9003 HTTP_PORT=9103 | |||
|
|||
run-sdk-conformance-test-node: | |||
$(MAKE) run-sdk-conformance-test SDK_FOLDER=node GRPC_PORT=9002 HTTP_PORT=9102 | |||
# run with on-by-default (Beta) feature flags enabled | |||
$(MAKE) run-sdk-conformance-test SDK_FOLDER=node GRPC_PORT=9002 HTTP_PORT=9102 TESTS=$(DEFAULT_CONFORMANCE_TESTS),$(COUNTS_AND_LISTS_TESTS) |
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.
By itself, this fails with error:
~/agones/build$ make run-sdk-conformance-test-node
...
> node ./testSDKClient.js
node:internal/modules/cjs/loader:1148
throw err;
^
Error: Cannot find module '@grpc/grpc-js'
Require stack:
- /go/src/agones.dev/agones/sdks/nodejs/src/agonesSDK.js
- /go/src/agones.dev/agones/sdks/nodejs/src/index.js
- /go/src/agones.dev/agones/test/sdk/nodejs/testSDKClient.js
at Module._resolveFilename (node:internal/modules/cjs/loader:1145:15)
at Module._load (node:internal/modules/cjs/loader:986:27)
at Module.require (node:internal/modules/cjs/loader:1233:19)
at require (node:internal/modules/helpers:179:18)
at Object.<anonymous> (/go/src/agones.dev/agones/sdks/nodejs/src/agonesSDK.js:15:14)
at Module._compile (node:internal/modules/cjs/loader:1358:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)
at Module.load (node:internal/modules/cjs/loader:1208:32)
at Module._load (node:internal/modules/cjs/loader:1024:12)
at Module.require (node:internal/modules/cjs/loader:1233:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/go/src/agones.dev/agones/sdks/nodejs/src/agonesSDK.js',
'/go/src/agones.dev/agones/sdks/nodejs/src/index.js',
'/go/src/agones.dev/agones/test/sdk/nodejs/testSDKClient.js'
]
}
Once I run ~/agones/build$ SDK_FOLDER=node make test-sdk
it installs the dependencies successfully, and then the command ~/agones/build$ make run-sdk-conformance-test-node
runs successfully. If there's not a quick way to check that the build script was run as part of the run-sdk-conformance-test-node
we should probably add a comment noting that SDK_FOLDER=node make test-sdk
needs to be run first.
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.
We would need to execute npm install
in the sdk folder, e.g. in build-sdk-test.sh the minimum required is
cd /go/src/agones.dev/agones/test/sdk/nodejs
npm install --quiet
Could we add something like that here? I don't know enough about these makefiles
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.
Probably not worth modifying the make command, since the test gets build properly during CI / CD, so this only applies to local testing. I added in a suggested comment change above.
- name: default | ||
portPolicy: Dynamic | ||
containerPort: 7654 | ||
counters: |
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.
Did you want the example to have the same counter and list as the local SDK Server? The sample local SDK server counters is "rooms" and lists is "players"
agones/pkg/sdkserver/localsdk.go
Lines 76 to 83 in 4b2910b
if runtime.FeatureEnabled(runtime.FeatureCountsAndLists) { | |
gs.Status.Counters = map[string]*sdk.GameServer_Status_CounterStatus{ | |
"rooms": {Count: 1, Capacity: 10}, | |
} | |
gs.Status.Lists = map[string]*sdk.GameServer_Status_ListStatus{ | |
"players": {Values: []string{"test0", "test1", "test2"}, Capacity: 100}, | |
} | |
} |
The unit tests for the SDK can be found in sdks/nodejs/spec/ and all the new functions were covered with unit tests in this file sdks/nodejs/spec/betaAgonesSDK.spec.js in the PR. These are the must have tests and can be run by using
There is an uncovered inner function in an error handler on line 103 of agonesSDK.js which may not be possible to test. It's unrelated to counts and lists. |
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. |
Build Succeeded 👏 Build Id: 0675c440-0b25-4c0b-a6c9-6102e035527f 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:
|
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.
LGTM. Thanks for all your work on this!
@@ -165,7 +165,8 @@ run-sdk-conformance-test-cpp: | |||
$(MAKE) run-sdk-conformance-test SDK_FOLDER=cpp GRPC_PORT=9003 HTTP_PORT=9103 | |||
|
|||
run-sdk-conformance-test-node: | |||
$(MAKE) run-sdk-conformance-test SDK_FOLDER=node GRPC_PORT=9002 HTTP_PORT=9102 | |||
# run with on-by-default (Beta) feature flags enabled | |||
$(MAKE) run-sdk-conformance-test SDK_FOLDER=node GRPC_PORT=9002 HTTP_PORT=9102 TESTS=$(DEFAULT_CONFORMANCE_TESTS),$(COUNTS_AND_LISTS_TESTS) |
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.
Probably not worth modifying the make command, since the test gets build properly during CI / CD, so this only applies to local testing. I added in a suggested comment change above.
Co-authored-by: igooch <igooch@google.com>
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. |
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. |
Build Failed 😱 Build Id: a5ee1237-fa39-429b-b8a1-5f01066c1e56 To get permission to view the Cloud Build view, join the agones-discuss Google Group. |
HTML tests failing after merging in main
|
Oh yep. Fix in #3847. This PR should be good to merge once the fix goes through. |
Build Failed 😱 Build Id: 8a22074e-7196-438f-95db-59623fdf143f To get permission to view the Cloud Build view, join the agones-discuss Google Group. |
@steven-supersolid we can never auto-update your PRs 😃 we're heading into the weekend, so please rebase against |
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. |
Build Succeeded 👏 Build Id: e92653c2-feda-4dc6-9564-04fe6bccff2e 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://togithub.com/googleforgames/agones)) | minor | `1.40.0` -> `1.41.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.41.0`](https://togithub.com/googleforgames/agones/blob/HEAD/CHANGELOG.md#v1410-2024-06-04) [Compare Source](https://togithub.com/googleforgames/agones/compare/v1.40.0...v1.41.0) [Full Changelog](https://togithub.com/googleforgames/agones/compare/v1.40.0...v1.41.0) **Implemented enhancements:** - Configure Allocator Status Code by [@​Kalaiselvi84](https://togithub.com/Kalaiselvi84) in [https://github.com/googleforgames/agones/pull/3782](https://togithub.com/googleforgames/agones/pull/3782) - Graduate Counters and Lists to Beta by [@​Kalaiselvi84](https://togithub.com/Kalaiselvi84) in [https://github.com/googleforgames/agones/pull/3801](https://togithub.com/googleforgames/agones/pull/3801) - Passthrough autopilot - Adds an AutopilotPassthroughPort Feature Gate and new pod label by [@​vicentefb](https://togithub.com/vicentefb) in [https://github.com/googleforgames/agones/pull/3809](https://togithub.com/googleforgames/agones/pull/3809) - CountsAndLists: Move to Beta Protobuf by [@​Kalaiselvi84](https://togithub.com/Kalaiselvi84) in [https://github.com/googleforgames/agones/pull/3806](https://togithub.com/googleforgames/agones/pull/3806) - feat: support multiple port ranges by [@​nrwiersma](https://togithub.com/nrwiersma) in [https://github.com/googleforgames/agones/pull/3747](https://togithub.com/googleforgames/agones/pull/3747) - Changes `sdk-server` to Patch instead of Update by [@​igooch](https://togithub.com/igooch) in [https://github.com/googleforgames/agones/pull/3803](https://togithub.com/googleforgames/agones/pull/3803) - Generate grpc for nodejs from alpha to beta by [@​lacroixthomas](https://togithub.com/lacroixthomas) in [https://github.com/googleforgames/agones/pull/3825](https://togithub.com/googleforgames/agones/pull/3825) - Update CountsAndLists from Alpha to Beta by [@​Kalaiselvi84](https://togithub.com/Kalaiselvi84) in [https://github.com/googleforgames/agones/pull/3824](https://togithub.com/googleforgames/agones/pull/3824) - feat(gameserver): New DirectToGameServer PortPolicy allows direct traffic to a GameServer by [@​daniellee](https://togithub.com/daniellee) in [https://github.com/googleforgames/agones/pull/3807](https://togithub.com/googleforgames/agones/pull/3807) - Passthrough autopilot - Adds mutating webhook by [@​vicentefb](https://togithub.com/vicentefb) in [https://github.com/googleforgames/agones/pull/3833](https://togithub.com/googleforgames/agones/pull/3833) - Passthrough autopilot - added ports array case and updated unit tests by [@​vicentefb](https://togithub.com/vicentefb) in [https://github.com/googleforgames/agones/pull/3842](https://togithub.com/googleforgames/agones/pull/3842) - Nodejs counters and lists by [@​steven-supersolid](https://togithub.com/steven-supersolid) in [https://github.com/googleforgames/agones/pull/3726](https://togithub.com/googleforgames/agones/pull/3726) - Promote AutopilotPassthroughPort feature gate to Alpha by [@​vicentefb](https://togithub.com/vicentefb) in [https://github.com/googleforgames/agones/pull/3849](https://togithub.com/googleforgames/agones/pull/3849) **Fixed bugs:** - Helm Param Update: Default to agones.controller if agones.extensions is Missing by [@​Kalaiselvi84](https://togithub.com/Kalaiselvi84) in [https://github.com/googleforgames/agones/pull/3773](https://togithub.com/googleforgames/agones/pull/3773) - fix: rollout strategy issues by [@​nrwiersma](https://togithub.com/nrwiersma) in [https://github.com/googleforgames/agones/pull/3762](https://togithub.com/googleforgames/agones/pull/3762) - Set Minimum Buffer Size to 1 by [@​Kalaiselvi84](https://togithub.com/Kalaiselvi84) in [https://github.com/googleforgames/agones/pull/3749](https://togithub.com/googleforgames/agones/pull/3749) - Pin ltsc2019 to older SHA by [@​zmerlynn](https://togithub.com/zmerlynn) in [https://github.com/googleforgames/agones/pull/3829](https://togithub.com/googleforgames/agones/pull/3829) - TestGameServerAllocationDuringMultipleAllocationClients: Readdress flake by [@​zmerlynn](https://togithub.com/zmerlynn) in [https://github.com/googleforgames/agones/pull/3831](https://togithub.com/googleforgames/agones/pull/3831) - Refactor finalizer name to include valid domain name and path by [@​indexjoseph](https://togithub.com/indexjoseph) in [https://github.com/googleforgames/agones/pull/3840](https://togithub.com/googleforgames/agones/pull/3840) - agones-{extensions,allocator}: Be more defensive about draining by [@​zmerlynn](https://togithub.com/zmerlynn) in [https://github.com/googleforgames/agones/pull/3839](https://togithub.com/googleforgames/agones/pull/3839) - agones-{extensions,allocator}: Pause after cancelling context by [@​zmerlynn](https://togithub.com/zmerlynn) in [https://github.com/googleforgames/agones/pull/3843](https://togithub.com/googleforgames/agones/pull/3843) - Change the line to modify in Quickstart: Edit a Game Server by [@​peterzhongyi](https://togithub.com/peterzhongyi) in [https://github.com/googleforgames/agones/pull/3844](https://togithub.com/googleforgames/agones/pull/3844) **Other:** - Prep for Release v1.41.0 by [@​Kalaiselvi84](https://togithub.com/Kalaiselvi84) in [https://github.com/googleforgames/agones/pull/3800](https://togithub.com/googleforgames/agones/pull/3800) - Update site documentation to reflect firewall prefix and default to Autopilot cluster creation for Agones by [@​vicentefb](https://togithub.com/vicentefb) in [https://github.com/googleforgames/agones/pull/3769](https://togithub.com/googleforgames/agones/pull/3769) - Add a System Diagram and overview page by [@​zmerlynn](https://togithub.com/zmerlynn) in [https://github.com/googleforgames/agones/pull/3792](https://togithub.com/googleforgames/agones/pull/3792) - Update Side Menu: Preserve and Restore Scroll Position by [@​Kalaiselvi84](https://togithub.com/Kalaiselvi84) in [https://github.com/googleforgames/agones/pull/3805](https://togithub.com/googleforgames/agones/pull/3805) - fix: typo by [@​skmpf](https://togithub.com/skmpf) in [https://github.com/googleforgames/agones/pull/3808](https://togithub.com/googleforgames/agones/pull/3808) - Helm Config: Add httpUnallocatedStatusCode in Allocator Service by [@​Kalaiselvi84](https://togithub.com/Kalaiselvi84) in [https://github.com/googleforgames/agones/pull/3802](https://togithub.com/googleforgames/agones/pull/3802) - Update Docs: CountersAndLists to Beta by [@​Kalaiselvi84](https://togithub.com/Kalaiselvi84) in [https://github.com/googleforgames/agones/pull/3810](https://togithub.com/googleforgames/agones/pull/3810) - Disable Dev feature FeatureAutopilotPassthroughPort by [@​vicentefb](https://togithub.com/vicentefb) in [https://github.com/googleforgames/agones/pull/3815](https://togithub.com/googleforgames/agones/pull/3815) - Disable FeatureAutopilotPassthroughPort in features.go by [@​vicentefb](https://togithub.com/vicentefb) in [https://github.com/googleforgames/agones/pull/3816](https://togithub.com/googleforgames/agones/pull/3816) - SDK proto compatibility guarantees and deprecation policies documentation by [@​igooch](https://togithub.com/igooch) in [https://github.com/googleforgames/agones/pull/3774](https://togithub.com/googleforgames/agones/pull/3774) - Fix dangling "as of" by [@​zmerlynn](https://togithub.com/zmerlynn) in [https://github.com/googleforgames/agones/pull/3827](https://togithub.com/googleforgames/agones/pull/3827) - Steps to Promote SDK Features from Alpha to Beta by [@​Kalaiselvi84](https://togithub.com/Kalaiselvi84) in [https://github.com/googleforgames/agones/pull/3814](https://togithub.com/googleforgames/agones/pull/3814) - Adds comment for help troubleshooting issues with terraform tfstate by [@​igooch](https://togithub.com/igooch) in [https://github.com/googleforgames/agones/pull/3822](https://togithub.com/googleforgames/agones/pull/3822) - docs: improve counter and list example comments by [@​yonbh](https://togithub.com/yonbh) in [https://github.com/googleforgames/agones/pull/3818](https://togithub.com/googleforgames/agones/pull/3818) - Skip /tmp/ on yamllint by [@​zmerlynn](https://togithub.com/zmerlynn) in [https://github.com/googleforgames/agones/pull/3838](https://togithub.com/googleforgames/agones/pull/3838) - TestAllocatorAfterDeleteReplica: More logging by [@​zmerlynn](https://togithub.com/zmerlynn) in [https://github.com/googleforgames/agones/pull/3837](https://togithub.com/googleforgames/agones/pull/3837) - Instructions for upgrading golang version by [@​gongmax](https://togithub.com/gongmax) in [https://github.com/googleforgames/agones/pull/3819](https://togithub.com/googleforgames/agones/pull/3819) - Remove unused function FindGameServerContainer by [@​zmerlynn](https://togithub.com/zmerlynn) in [https://github.com/googleforgames/agones/pull/3841](https://togithub.com/googleforgames/agones/pull/3841) - Adds Unreal to the List of URL Links to Not Check by [@​igooch](https://togithub.com/igooch) in [https://github.com/googleforgames/agones/pull/3847](https://togithub.com/googleforgames/agones/pull/3847) - docs: clarify virtualization setup for Windows versions by [@​andresromerodev](https://togithub.com/andresromerodev) in [https://github.com/googleforgames/agones/pull/3850](https://togithub.com/googleforgames/agones/pull/3850) **New Contributors:** - [@​skmpf](https://togithub.com/skmpf) made their first contribution in [https://github.com/googleforgames/agones/pull/3808](https://togithub.com/googleforgames/agones/pull/3808) - [@​yonbh](https://togithub.com/yonbh) made their first contribution in [https://github.com/googleforgames/agones/pull/3818](https://togithub.com/googleforgames/agones/pull/3818) - [@​peterzhongyi](https://togithub.com/peterzhongyi) made their first contribution in [https://github.com/googleforgames/agones/pull/3844](https://togithub.com/googleforgames/agones/pull/3844) - [@​andresromerodev](https://togithub.com/andresromerodev) made their first contribution in [https://github.com/googleforgames/agones/pull/3850](https://togithub.com/googleforgames/agones/pull/3850) </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://togithub.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4zOTAuMCIsInVwZGF0ZWRJblZlciI6IjM3LjM5MC4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJyZW5vdmF0ZS9oZWxtIiwidHlwZS9taW5vciJdfQ==-->
What type of PR is this?
/kind feature
What this PR does / Why we need it:
Which issue(s) this PR fixes:
Closes #3645
Special notes for your reviewer: