agones-{extensions,allocator}: Make servers context aware#3845
agones-{extensions,allocator}: Make servers context aware#3845markmandel merged 6 commits intoagones-dev:mainfrom
Conversation
|
Build Failed 😱 Build Id: f71cd44c-de3c-458c-9dd6-aa9f3dd9b3ee To get permission to view the Cloud Build view, join the agones-discuss Google Group. |
|
Hmm, upon further testing this still has a minor flake. Let me play with it a bit more, moving to draft. |
|
Build Failed 😱 Build Id: 6355c010-ac46-4c04-92cf-5fee63fbdc1f To get permission to view the Cloud Build view, join the agones-discuss Google Group. |
|
Build Succeeded 👏 Build Id: cb48cb0a-06e7-485a-87ca-f0a79097eb43 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:
|
| kubeInformerFactory := informers.NewSharedInformerFactory(kubeClient, defaultResync) | ||
|
|
||
| server := &httpServer{} | ||
| server := &httpserver.Server{Logger: logger} |
There was a problem hiding this comment.
| server := &httpserver.Server{Logger: logger} | |
| server := &http.Server{Logger: logger} |
That wouldn't be redundant 😃
|
|
||
| // Package httpserver implements an http server that conforms to the | ||
| // controller runner interface. | ||
| package httpserver |
There was a problem hiding this comment.
| package httpserver | |
| package http |
I'd be tempted to make the package http since we also have a https - not sure the server part is required.
There was a problem hiding this comment.
I really didn't want to shadow a super commonly important base library. Calling this http would result in it getting imported as agoneshttp or something pretty often, since I would also probably not rename base http.
|
Build Succeeded 👏 Build Id: ec4f214a-d587-406d-8ee0-20be8a5a2b15 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:
|
cmd/allocator/main.go
Outdated
| go func() { | ||
| go func() { | ||
| <-ctx.Done() | ||
| grpcServer.Stop() |
There was a problem hiding this comment.
Should this be: https://pkg.go.dev/google.golang.org/grpc#Server.GracefulStop (or maybe used in lieu of a lot of this code?)
Which might help with your multi-context issue?
There was a problem hiding this comment.
I went back and forth on this, and I have a version in a branch where I did exactly that. It made things worse.
Let me just go back to the drawing board here, but I think it may involve rewriting a lot of the handling basically everywhere.
There was a problem hiding this comment.
But no, it doesn't solve the two-context issue. The problem is that here (and in httpserver/https), we use a context to signal shutdown, but the service handler still needs a forward context to get work done to shut down. Let me see if I can just rework the listen handlers more.
There was a problem hiding this comment.
Yeah I see your point. I think you are right that we'll want two contexts, but what we could do is something akin to:
<- listenerCtx.Done()
// graceful shutdown both the http and grpc listeners.
grpcServer.GracefulStop()
server.Shutdown()
cancelInfrormer() // cancel the worker + Informer context, since now we know we aren't accepting any more connections.This might require pulling the grpc + http listeners into a larger struct that has a Run(ctx) operation on it, and stops when the ctx is <- ctx.Done(), to provide a larger data structure to operate on (and then it could take a context, and manage it's own context for the workers and informers).
Did that make sense?
There was a problem hiding this comment.
Hmm, we could do something similar to the runner slices and have shutdown slices, perhaps?
There was a problem hiding this comment.
Hmm, we could do something similar to the runner slices and have shutdown slices, perhaps?
Seems like you are rebuilding Contexts 😄
…ealth check * adds an `httpserver` utility package to handle the `Run` function that controller/extensions use. Make that context aware using the same method as https.Run: https://github.com/googleforgames/agones/blob/dfa414e5e4da37798833bbf8c33919acb5f3c2ea/pkg/util/https/server.go#L127-L130 * also plumbs context-awareness through the allocator run{Mux,REST,GRPC} functions. * adds a gRPC health server to the allocator, calls .Shutdown() on it during graceful termination - this seems to push the client off correctly. Tested with e2e in a loop. Towards #3853
|
Build Succeeded 👏 Build Id: 4e70c09c-b912-48d4-91fb-6af56029445b 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:
|
| // and a cascading graceful shutdown instead of multiple contexts and sleeps. | ||
| <-listenCtx.Done() | ||
| logger.Infof("Listen context cancelled") | ||
| time.Sleep(5 * time.Second) |
There was a problem hiding this comment.
I'm assuming this is because we don't actually know that the gRPC/HTTP servers have gracefully shut down yet, so we just wait for a bit?
There was a problem hiding this comment.
Yeah .. fully knowing they're done takes a bit more plumbing.
|
Build Succeeded 👏 Build Id: 6e64e3f3-f0bb-4499-8566-4b744130ea83 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:
|
markmandel
left a comment
There was a problem hiding this comment.
Good enough 😁 thanks for all the new plumbing!
|
Build Succeeded 👏 Build Id: 841fae19-753d-41d2-a8c5-4b3b68f7ad80 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:
|
…#3845) * agones-{extensions,allocator}: Make servers context aware, add gRPC health check * adds an `httpserver` utility package to handle the `Run` function that controller/extensions use. Make that context aware using the same method as https.Run: https://github.com/googleforgames/agones/blob/dfa414e5e4da37798833bbf8c33919acb5f3c2ea/pkg/util/https/server.go#L127-L130 * also plumbs context-awareness through the allocator run{Mux,REST,GRPC} functions. * adds a gRPC health server to the allocator, calls .Shutdown() on it during graceful termination - this seems to push the client off correctly. Tested with e2e in a loop. Towards agones-dev#3853 * Move from context.Background() * Use Shutdown/GracefulStop * Relax deadline slightly (original had none), also delete pod from GetAllocatorClient
… apis (agones-dev#3900) * Adds a command to generate the zz_generated.deepcopy.go files for the apis * Combines CRD client and deepcopy code generation into one script * Updates boilerplate headers to 2024 * Generated code from gen-all-sdk-grpc * Small update to template comment agones-{extensions,allocator}: Make servers context aware (agones-dev#3845) * agones-{extensions,allocator}: Make servers context aware, add gRPC health check * adds an `httpserver` utility package to handle the `Run` function that controller/extensions use. Make that context aware using the same method as https.Run: https://github.com/googleforgames/agones/blob/dfa414e5e4da37798833bbf8c33919acb5f3c2ea/pkg/util/https/server.go#L127-L130 * also plumbs context-awareness through the allocator run{Mux,REST,GRPC} functions. * adds a gRPC health server to the allocator, calls .Shutdown() on it during graceful termination - this seems to push the client off correctly. Tested with e2e in a loop. Towards agones-dev#3853 * Move from context.Background() * Use Shutdown/GracefulStop * Relax deadline slightly (original had none), also delete pod from GetAllocatorClient Update Slack invite link (agones-dev#3896) Looks like the Slack invite link expired somewhere along the way, so this is a new, shiny updated one!
… apis (agones-dev#3900) * Adds a command to generate the zz_generated.deepcopy.go files for the apis * Combines CRD client and deepcopy code generation into one script * Updates boilerplate headers to 2024 * Generated code from gen-all-sdk-grpc * Small update to template comment agones-{extensions,allocator}: Make servers context aware (agones-dev#3845) * agones-{extensions,allocator}: Make servers context aware, add gRPC health check * adds an `httpserver` utility package to handle the `Run` function that controller/extensions use. Make that context aware using the same method as https.Run: https://github.com/googleforgames/agones/blob/dfa414e5e4da37798833bbf8c33919acb5f3c2ea/pkg/util/https/server.go#L127-L130 * also plumbs context-awareness through the allocator run{Mux,REST,GRPC} functions. * adds a gRPC health server to the allocator, calls .Shutdown() on it during graceful termination - this seems to push the client off correctly. Tested with e2e in a loop. Towards agones-dev#3853 * Move from context.Background() * Use Shutdown/GracefulStop * Relax deadline slightly (original had none), also delete pod from GetAllocatorClient Update Slack invite link (agones-dev#3896) Looks like the Slack invite link expired somewhere along the way, so this is a new, shiny updated one!
… apis (agones-dev#3900) * Adds a command to generate the zz_generated.deepcopy.go files for the apis * Combines CRD client and deepcopy code generation into one script * Updates boilerplate headers to 2024 * Generated code from gen-all-sdk-grpc * Small update to template comment agones-{extensions,allocator}: Make servers context aware (agones-dev#3845) * agones-{extensions,allocator}: Make servers context aware, add gRPC health check * adds an `httpserver` utility package to handle the `Run` function that controller/extensions use. Make that context aware using the same method as https.Run: https://github.com/googleforgames/agones/blob/dfa414e5e4da37798833bbf8c33919acb5f3c2ea/pkg/util/https/server.go#L127-L130 * also plumbs context-awareness through the allocator run{Mux,REST,GRPC} functions. * adds a gRPC health server to the allocator, calls .Shutdown() on it during graceful termination - this seems to push the client off correctly. Tested with e2e in a loop. Towards agones-dev#3853 * Move from context.Background() * Use Shutdown/GracefulStop * Relax deadline slightly (original had none), also delete pod from GetAllocatorClient Update Slack invite link (agones-dev#3896) Looks like the Slack invite link expired somewhere along the way, so this is a new, shiny updated one!
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==-->
httpserverutility package to handle theRunfunction that controller/extensions use. Make that context aware using the same method as https.Run: https://github.com/googleforgames/agones/blob/dfa414e5e4da37798833bbf8c33919acb5f3c2ea/pkg/util/https/server.go#L127-L130Along the way, basically re-wrote the
TestAllocatorAfterDeleteReplicatest:GetAllocatorClientup because it's fairly disruptive (new certs, etc.), so I wanted the pod stability checks to happen afteragones-allocatorstability checks to just grab the Deployment and wait forReplicas != AvailableReplicas.Tested with e2e in a loop.
Towards #3853