-
Notifications
You must be signed in to change notification settings - Fork 818
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
refactor simple game server #3817
refactor simple game server #3817
Conversation
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: 72700498-8b76-4a75-8bea-5879ed4cd3a9 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.
Approach looks good! Some nits, and some other ideas to try.
@@ -0,0 +1,331 @@ | |||
package main |
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.
Apache licence header please.
func ready(s *sdk.SDK) { | ||
err := s.Ready() | ||
if err != nil { | ||
log.Fatalf("Could not send ready 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.
So I am noting that we have a pattern that looks like the above quite a bit - execute a function on the SDK, if it fails, log.Fatalf(...)
Not 100% sure how useful this would be - as it may only apply in a few places, but something like:
func runSDK(f func() err, failMsg string) {
if err := f(); err != nil {
log.Fatalf(failMsg + ": %v", err)
}
}
Then this function could pretty much go away and you could do inline in handleReady
func handleReady(s *sdk.SDK, parts []string, _ ...context.CancelFunc) (response string, addACK bool, responseError error) {
runSDK(func() err { return s.Ready() }, "Could not send ready message")
}
Since it's a closure, it could also handle anything taking in a series of arguments.
Where it goes fall over is if a SDK function returns several return values -- so it may not be worth it. But figured I'd show you my general idea, and see if it made sense -- save writing two functions for each command.
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.
So I am noting that we have a pattern that looks like the above quite a bit - execute a function on the SDK, if it fails,
log.Fatalf(...)
Not 100% sure how useful this would be - as it may only apply in a few places, but something like:
func runSDK(f func() err, failMsg string) { if err := f(); err != nil { log.Fatalf(failMsg + ": %v", err) } }Then this function could pretty much go away and you could do inline in
handleReady
func handleReady(s *sdk.SDK, parts []string, _ ...context.CancelFunc) (response string, addACK bool, responseError error) { runSDK(func() err { return s.Ready() }, "Could not send ready message") }Since it's a closure, it could also handle anything taking in a series of arguments.
Where it goes fall over is if a SDK function returns several return values -- so it may not be worth it. But figured I'd show you my general idea, and see if it made sense -- save writing two functions for each command.
Ahan! I got it. I have added all the sdk functions inside the handlers.
@@ -0,0 +1,371 @@ | |||
package main |
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.
rename suggestion: handlers.go
@@ -0,0 +1,331 @@ | |||
package main |
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.
Rename suggestions : sdk.go
(don't love it) - but helpers.go
is a bit ambiguous. sdk.go
gives some idea that this is where the sdk gets called.
Either that or pull it all into handers.go
and put the SDK command under each handler? (or if need be, make it inline?)
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.
Rename suggestions :
sdk.go
(don't love it) - buthelpers.go
is a bit ambiguous.sdk.go
gives some idea that this is where the sdk gets called.Either that or pull it all into
handers.go
and put the SDK command under each handler? (or if need be, make it inline?)
I have pulled everything inside handlers.go
. sdk.go isn't required.
Thank you so much for your guidance.
8b83ca3
to
7a03c71
Compare
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: c54e02bb-849e-45cd-83ba-9885bf4fa113 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.
Looks good!
Will need an increment on the version number:
version := 0.32 |
Will also need to update all the references to simple-game-server - but may want to test locally with some e2e tests before updating everything as we'll need to push a new version to prod.
@@ -0,0 +1,581 @@ | |||
// Copyright 2020 Google LLC All Rights Reserved. |
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.
// Copyright 2020 Google LLC All Rights Reserved. | |
// Copyright 2024 Google LLC All Rights Reserved. |
7a03c71
to
253638e
Compare
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. |
I had tested few functionalities mentioned in this file: https://github.com/googleforgames/agones/blob/main/test/e2e/gameserver_test.go#L717. Everything works perfectly to me. I was communicated with gameserver (https://agones.dev/site/docs/getting-started/create-gameserver/#3-connect-to-the-gameserver) the response was as expected. Please, let me know what else i am missing for e2e test. |
Build Failed 😱 Build Id: 2eb3c057-1ad5-4c69-9e20-40a830f1b884 To get permission to view the Cloud Build view, join the agones-discuss Google Group. |
253638e
to
7c8810f
Compare
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: bdcd983b-76c0-4aba-be39-cbf32599be5f To get permission to view the Cloud Build view, join the agones-discuss Google Group. |
Hi @markmandel,
Could you please guide why this is failing. There are other functions also failing in allocator_test.go file. |
It's possible it's failing because the simple game server image 0.33 is not in the Agones artifact registry yet. You can test if that's the issue locally by pushing the simple game server image to your dev project's artifact registry https://github.com/googleforgames/agones/blob/main/examples/simple-game-server/Makefile and temporarily changing the image to your repo image agones/test/e2e/framework/framework.go Line 153 in bff72b1
|
As part of this PR, try out the approach(es) in #3836 and see if they work for you 👍🏻 |
7c8810f
to
636f807
Compare
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: ded8d76c-7d0f-4290-bf8e-6b840b5f906b To get permission to view the Cloud Build view, join the agones-discuss Google Group. |
636f807
to
3ee108f
Compare
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: 93ea63f6-853d-4104-a5af-6fa11f8b1d70 To get permission to view the Cloud Build view, join the agones-discuss Google Group. |
build/Makefile
Outdated
@@ -64,7 +64,7 @@ KIND_PROFILE ?= agones | |||
KIND_CONTAINER_NAME=$(KIND_PROFILE)-control-plane | |||
|
|||
# Game Server image to use while doing end-to-end tests | |||
GS_TEST_IMAGE ?= us-docker.pkg.dev/agones-images/examples/simple-game-server:0.32 | |||
GS_TEST_IMAGE ?= us-central1-docker.pkg.dev/agones-ashutoshnsingh/example/simple-game-server:0.33-dev-linux-amd64 |
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 expect this won't work, since the agones-images
project doesn't have access to your artifact registry.
You could make it public if yo u desired though 😄 at least temporarily.
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.
Thanks a lot @markmandel. It worked perfectly.
3ee108f
to
e2f17f4
Compare
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: cbe7023a-7c96-4571-870d-a23ed4285820 To get permission to view the Cloud Build view, join the agones-discuss Google Group. |
e2f17f4
to
42c7843
Compare
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: 30608748-02a4-49c9-8040-fc7115fbe729 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: 254786fa-3d32-4495-8ee8-ae24ac80f490 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.
Looks great! Let's get the new image up to prod and switch over to using it 👍🏻
test/e2e/framework/framework.go
Outdated
@@ -799,7 +799,7 @@ func (f *Framework) DefaultGameServer(namespace string) *agonesv1.GameServer { | |||
Containers: []corev1.Container{{ | |||
Name: "game-server", | |||
Image: f.GameServerImage, | |||
ImagePullPolicy: corev1.PullIfNotPresent, | |||
ImagePullPolicy: corev1.PullAlways, |
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.
Before we close off this PR, let's move this back to PullIfNotPresent
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.
Done! Added the new image to prod. Also updated the new image in all the files. Could you please review it and merge it?
5a1d70b
to
1614bf0
Compare
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: a494d89a-3aca-44ed-a13d-453fef3833a1 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
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: 5f5f5998-b3b5-4c2f-9152-491a909ffe58 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.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://togithub.com/googleforgames/agones/blob/HEAD/CHANGELOG.md#v1420-2024-07-16) [Compare Source](https://togithub.com/googleforgames/agones/compare/v1.41.0...v1.42.0) [Full Changelog](https://togithub.com/googleforgames/agones/compare/v1.41.0...v1.42.0) **Breaking changes:** - Update csharp.md to indicate ConnectAsync is deprecated by [@​aallbrig](https://togithub.com/aallbrig) in [https://github.com/googleforgames/agones/pull/3866](https://togithub.com/googleforgames/agones/pull/3866) **Implemented enhancements:** - Add security context to Agones containers by [@​peterzhongyi](https://togithub.com/peterzhongyi) in [https://github.com/googleforgames/agones/pull/3856](https://togithub.com/googleforgames/agones/pull/3856) - Add Security Context to game server sidecar by [@​peterzhongyi](https://togithub.com/peterzhongyi) in [https://github.com/googleforgames/agones/pull/3869](https://togithub.com/googleforgames/agones/pull/3869) - Drop CountsAndLists Data from the Fleet and Game Server Set When the Flag is False by [@​igooch](https://togithub.com/igooch) in [https://github.com/googleforgames/agones/pull/3881](https://togithub.com/googleforgames/agones/pull/3881) - Adds tests to confirm that Fleet, Fleet Autoscaler, and Fleet Allocation apply defaults code is idempotent by [@​igooch](https://togithub.com/igooch) in [https://github.com/googleforgames/agones/pull/3888](https://togithub.com/googleforgames/agones/pull/3888) - feat: Add CRD Changes and Feature Flag for chain policy by [@​indexjoseph](https://togithub.com/indexjoseph) in [https://github.com/googleforgames/agones/pull/3880](https://togithub.com/googleforgames/agones/pull/3880) **Fixed bugs:** - sdk-server expects SDK_LOG_LEVEL by [@​KAllan357](https://togithub.com/KAllan357) in [https://github.com/googleforgames/agones/pull/3858](https://togithub.com/googleforgames/agones/pull/3858) - this will resolve From/layer extraction issue on ltsc2019 in examples by [@​ashutosji](https://togithub.com/ashutosji) in [https://github.com/googleforgames/agones/pull/3873](https://togithub.com/googleforgames/agones/pull/3873) - featuregate: adds validation if PortPolicyNone is not enabled by [@​daniellee](https://togithub.com/daniellee) in [https://github.com/googleforgames/agones/pull/3871](https://togithub.com/googleforgames/agones/pull/3871) - added local as default for registry when registry is not specified by [@​kamaljeeti](https://togithub.com/kamaljeeti) in [https://github.com/googleforgames/agones/pull/3876](https://togithub.com/googleforgames/agones/pull/3876) - Buffer Unity SDK ReceiveData when watching for configuration changes by [@​ZeroParticle](https://togithub.com/ZeroParticle) in [https://github.com/googleforgames/agones/pull/3872](https://togithub.com/googleforgames/agones/pull/3872) - agones-{extensions,allocator}: Make servers context aware by [@​zmerlynn](https://togithub.com/zmerlynn) in [https://github.com/googleforgames/agones/pull/3845](https://togithub.com/googleforgames/agones/pull/3845) - added condition for distributed logic by [@​ashutosji](https://togithub.com/ashutosji) in [https://github.com/googleforgames/agones/pull/3877](https://togithub.com/googleforgames/agones/pull/3877) **Security fixes:** - Bump [@​grpc/grpc-js](https://togithub.com/grpc/grpc-js) from 1.10.7 to 1.10.9 in /sdks/nodejs by [@​dependabot](https://togithub.com/dependabot) in [https://github.com/googleforgames/agones/pull/3863](https://togithub.com/googleforgames/agones/pull/3863) **Other:** - Preparation for Release v1.42.0 by [@​ashutosji](https://togithub.com/ashutosji) in [https://github.com/googleforgames/agones/pull/3854](https://togithub.com/googleforgames/agones/pull/3854) - Add helpful note to edit-first-gameserver-go by [@​peterzhongyi](https://togithub.com/peterzhongyi) in [https://github.com/googleforgames/agones/pull/3846](https://togithub.com/googleforgames/agones/pull/3846) - Moved Passthrough feature description to the correct section in Feature Stages by [@​vicentefb](https://togithub.com/vicentefb) in [https://github.com/googleforgames/agones/pull/3861](https://togithub.com/googleforgames/agones/pull/3861) - Updated Node.js Page to Reflect that Counters and Lists is Implemented by [@​ashutosji](https://togithub.com/ashutosji) in [https://github.com/googleforgames/agones/pull/3865](https://togithub.com/googleforgames/agones/pull/3865) - Change Slack channel description from #developers to #development by [@​branhoff](https://togithub.com/branhoff) in [https://github.com/googleforgames/agones/pull/3868](https://togithub.com/googleforgames/agones/pull/3868) - updated UpdateList documentation for local sdk server and sdk server by [@​ashutosji](https://togithub.com/ashutosji) in [https://github.com/googleforgames/agones/pull/3878](https://togithub.com/googleforgames/agones/pull/3878) - Add zio-agones to the list of third party client SDKs by [@​ghostdogpr](https://togithub.com/ghostdogpr) in [https://github.com/googleforgames/agones/pull/3875](https://togithub.com/googleforgames/agones/pull/3875) - refactor simple game server by [@​ashutosji](https://togithub.com/ashutosji) in [https://github.com/googleforgames/agones/pull/3817](https://togithub.com/googleforgames/agones/pull/3817) - Update Slack invite link by [@​markmandel](https://togithub.com/markmandel) in [https://github.com/googleforgames/agones/pull/3896](https://togithub.com/googleforgames/agones/pull/3896) - Added cleanup for app-engine services in cloudbuild script by [@​kamaljeeti](https://togithub.com/kamaljeeti) in [https://github.com/googleforgames/agones/pull/3890](https://togithub.com/googleforgames/agones/pull/3890) - Adds a command to generate the zz_generated.deepcopy.go files for the apis by [@​igooch](https://togithub.com/igooch) in [https://github.com/googleforgames/agones/pull/3900](https://togithub.com/googleforgames/agones/pull/3900) - update go version to 1.21.12 by [@​ashutosji](https://togithub.com/ashutosji) in [https://github.com/googleforgames/agones/pull/3894](https://togithub.com/googleforgames/agones/pull/3894) **New Contributors:** - [@​KAllan357](https://togithub.com/KAllan357) made their first contribution in [https://github.com/googleforgames/agones/pull/3858](https://togithub.com/googleforgames/agones/pull/3858) - [@​branhoff](https://togithub.com/branhoff) made their first contribution in [https://github.com/googleforgames/agones/pull/3868](https://togithub.com/googleforgames/agones/pull/3868) - [@​aallbrig](https://togithub.com/aallbrig) made their first contribution in [https://github.com/googleforgames/agones/pull/3866](https://togithub.com/googleforgames/agones/pull/3866) - [@​ZeroParticle](https://togithub.com/ZeroParticle) made their first contribution in [https://github.com/googleforgames/agones/pull/3872](https://togithub.com/googleforgames/agones/pull/3872) - [@​ghostdogpr](https://togithub.com/ghostdogpr) made their first contribution in [https://github.com/googleforgames/agones/pull/3875](https://togithub.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://togithub.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40MzIuMCIsInVwZGF0ZWRJblZlciI6IjM3LjQzMi4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJyZW5vdmF0ZS9oZWxtIiwidHlwZS9taW5vciJdfQ==-->
What type of PR is this? This is a refactor of existing code of simple game server present in examples folder.
What this PR does / Why we need it:
Which issue(s) this PR fixes: #3813
Closes #3813
Special notes for your reviewer: