Skip to content
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

Add labels and annotations to allocation response #3197

Merged

Conversation

austin-space
Copy link
Contributor

@austin-space austin-space commented Jun 1, 2023

What type of PR is this?

/kind feature

What this PR does / Why we need it:
This PR is not complete. It almost certainly needs more tests and I haven't touched the documentation. I'm mostly looking for a quick gut check to see if I'm missing anything glaring.

This PR returns the labels and annotations of an allocated game server at allocation time with the allocation response or Allocation CR status. This opens up a few very interesting scenarios:

  • the ability to get some information from the game server that was generated by the game server(additional connection info)
  • the ability to game server state information(such as map or hardware class)
  • the ability to get insight into how allocations are getting processed(for example, we can get an idea of how far we're falling through our allocation selector chain)

Which issue(s) this PR fixes:

Closes #2396

Special notes for your reviewer:
I tried to break out the changes I've made thus far into two commits: the first being my changes, the second being the result of running the various gen make commands. Hopefully this makes this PR a little more readable. I undid most of the autogen stuff since the sdk autogen stuff appears to be broken(related to the counts and lists changes it seems).

Also worth noting that I originally tried to put this behind a feature flag, but I don't think that actually makes much sense since the fields will be in the protobuf no matter whether we put something in there or not and it could potentially be confusing for users since there is no alpha allocation protobuf. If you want I can add the feature flag back.

@agones-bot
Copy link
Collaborator

Build Failed 😱

Build Id: 8e006635-244e-4c48-b9e0-b6522e067006

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

@gongmax
Copy link
Collaborator

gongmax commented Jun 1, 2023

linter failure

pkg/apis/allocation/v1/gameserverallocation.go:614:6: exported: exported type GameServerMetadata should have comment or be unexported (revive)
type GameServerMetadata struct {
     ^

@agones-bot
Copy link
Collaborator

Build Failed 😱

Build Id: 1adb67bb-0a91-4f46-9fbe-956fbef0d01d

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

@google-oss-prow google-oss-prow bot added size/L and removed size/XXL labels Jun 1, 2023
@austin-space austin-space changed the title Austin/add labels and annotations Add labels and annotations to allocation response Jun 1, 2023
@austin-space
Copy link
Contributor Author

I removed the sdk generation and a change I had made to get that working for node js. Just as a heads up, it seems like that may have been broken since the last time someone made changes to the protobuf a few months ago.

@agones-bot
Copy link
Collaborator

Build Failed 😱

Build Id: 83d79f82-28e7-46e3-b67d-aedb92ac0a81

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

@agones-bot
Copy link
Collaborator

Build Failed 😱

Build Id: 569616a3-0c59-424a-932f-3ea2814a6fdb

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

@google-oss-prow google-oss-prow bot added size/XXL and removed size/L labels Jun 2, 2023
@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: 2b15d7b9-0cfe-43e0-bb7e-c973c9f66a33

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/3197/head:pr_3197 && git checkout pr_3197
  • 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.33.0-6da62ab-amd64

Copy link
Member

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

Thanks for doing all this work! Added a few questions inline.

Only other things I can think of to add:

  1. Updates to the documentation, at the very least the GameServerAllocation Specification
  2. Update to the example (which is basically the same as above) https://github.com/googleforgames/agones/blob/main/examples/gameserverallocation.yaml
  3. End to end tests , could probably extend what we already have, primarily:

func TestCreateFleetAndGameServerAllocate(t *testing.T) {

and

func TestAllocatorWithSelectors(t *testing.T) {

Will suffice.

But really excited to have this in Agones!

@gongmax @zmerlynn - do we see any reason to put this behind a feature gate? I think it's likely fine, since I can't think of anything we'd want to change in this, but figured I would ask.

proto/allocation/allocation.proto Show resolved Hide resolved
@zmerlynn
Copy link
Collaborator

zmerlynn commented Jun 9, 2023

@gongmax @zmerlynn - do we see any reason to put this behind a feature gate? I think it's likely fine, since I can't think of anything we'd want to change in this, but figured I would ask.

Since it's a new return from the API, I can't imagine needing a feature gate - rather, I think the question is whether it should be introduced straight to the v1 surface or go through the beta API surface first. I think the answer to that is still no, though - I'm ok with this going straight to v1.

@gongmax
Copy link
Collaborator

gongmax commented Jun 9, 2023

@gongmax @zmerlynn - do we see any reason to put this behind a feature gate? I think it's likely fine, since I can't think of anything we'd want to change in this, but figured I would ask.

Since it's a new return from the API, I can't imagine needing a feature gate - rather, I think the question is whether it should be introduced straight to the v1 surface or go through the beta API surface first. I think the answer to that is still no, though - I'm ok with this going straight to v1.

I agreed. Previously we introduced the Source field in allocation response, which was not behind a feature gate. I cannot think of any drawback to not follow the same pattern.

@markmandel
Copy link
Member

SGTM!

in which case one we have some docs, examples and e2e tests, this should be good to merge 👍🏻 🤸🏻

@agones-bot
Copy link
Collaborator

Build Failed 😱

Build Id: 609091b9-9d7f-4996-8d0b-628d7a73f7a2

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

@agones-bot
Copy link
Collaborator

Build Failed 😱

Build Id: 5efa7beb-70f5-42c3-abf9-5c6086613f73

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

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: 7776b798-09ee-43fe-a956-e4381c0ed92f

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/3197/head:pr_3197 && git checkout pr_3197
  • 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.33.0-afd3a51-amd64

@google-oss-prow google-oss-prow bot added size/L and removed size/XXL labels Jun 15, 2023
@austin-space
Copy link
Contributor Author

Assuming this build succeeds, this pr should be ready for another round of review

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: f2d4b4f5-ab86-46ba-b7ad-e19a6eb4c24c

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/3197/head:pr_3197 && git checkout pr_3197
  • 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.33.0-7acb057-amd64

Copy link
Member

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

Looks good! Added some notes on some code cleanup.

One extra e2e test to add and I think we're good to go:
https://github.com/googleforgames/agones/blob/main/test/e2e/allocator_test.go

Just to e2e test the conversion to grpc and rest work as expected - you could even just add labels and annotations to the existing tests rather than spin up a whole new one if that's easier (also avoids waiting for the tls certs to refresh any more).

site/content/en/docs/Reference/gameserverallocation.md Outdated Show resolved Hide resolved
test/e2e/gameserverallocation_test.go Outdated Show resolved Hide resolved
test/e2e/gameserverallocation_test.go Outdated Show resolved Hide resolved
@@ -16,7 +16,7 @@
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
// versions:
// - protoc-gen-go-grpc v1.2.0
// - protoc v3.21.6
// - protoc v3.21.12
Copy link
Member

Choose a reason for hiding this comment

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

🤔 wondering why this is here? (and in the other sdk files)

Copy link
Contributor Author

@austin-space austin-space Jun 16, 2023

Choose a reason for hiding this comment

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

That's a good question, and one I can't answer. I don't have a standalone install of protoc on my machine. Something I did notice is that some of the protobuf seems to have not been generated for some client libraries in some time(if you run it on main, it fails) so this may be an artifact of that?

Copy link
Member

Choose a reason for hiding this comment

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

Ooh I see - this is an artifact of running the make gen-allocation-grpc? (I would have thought it would have only happened for make gen-sdk-grpc 🤔 weird.

I mean it's a change in a comment - not the end of the world 🤷🏻 weird though.

austin-space and others added 4 commits June 16, 2023 15:31
Co-authored-by: Mark Mandel <markmandel@google.com>
Co-authored-by: Mark Mandel <markmandel@google.com>
Co-authored-by: Mark Mandel <markmandel@google.com>
@agones-bot
Copy link
Collaborator

Build Failed 😱

Build Id: a38915d6-ec0a-4bfc-807e-c4ad20279d94

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

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: c04eb646-4e5c-4901-908e-bf50505f76fd

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/3197/head:pr_3197 && git checkout pr_3197
  • 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.33.0-6bbc04f-amd64

Copy link
Member

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

Looks good! Sorry about the delay in final approval!

@@ -208,6 +208,7 @@ func TestAllocatorWithSelectors(t *testing.T) {
require.NoError(t, err)
require.Equal(t, response.GameServerName, allocatedResponse.GameServerName)
helper.ValidateAllocatorResponse(t, allocatedResponse)
assert.Equal(t, flt.ObjectMeta.Name, allocatedResponse.Metadata.Labels[agonesv1.FleetNameLabel])
Copy link
Member

Choose a reason for hiding this comment

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

Clever!

@google-oss-prow
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: austin-space, markmandel

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@markmandel markmandel enabled auto-merge (squash) June 22, 2023 21:23
@google-oss-prow google-oss-prow bot removed the lgtm label Jun 22, 2023
@google-oss-prow
Copy link

New changes are detected. LGTM label has been removed.

@markmandel markmandel added kind/feature New features for Agones lgtm labels Jun 22, 2023
@markmandel markmandel merged commit e287cc3 into googleforgames:main Jun 22, 2023
@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: 6881c65f-9871-4eb5-b2cf-d61750d52fd7

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/3197/head:pr_3197 && git checkout pr_3197
  • 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.33.0-dev-67b225e-amd64

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: 5508d002-df3c-425b-9011-231d35c00f9e

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/3197/head:pr_3197 && git checkout pr_3197
  • 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.33.0-dev-67b225e-amd64

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Return labels and annotations with GameServerAllocation results.
5 participants