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

Return HTTP 201 on GameServerAllocation #2110

Merged
merged 1 commit into from
May 27, 2021

Conversation

markmandel
Copy link
Member

What type of PR is this?

Uncomment only one /kind <> line, press enter to put that in a new line, and remove leading whitespace from that line:

/kind breaking

/kind bug

/kind cleanup
/kind documentation
/kind feature
/kind hotfix

What this PR does / Why we need it:

The standard for CRD creation is to return a HTTP 201 response. The Go client is more flexible and was happy with a 200 response, but the C# client will error out if anything but a 201 response.

This fixes things so we send the correct HTTP response code when creating a GameServerAllocation.

Which issue(s) this PR fixes:

Closes #2108

Special notes for your reviewer:

N/A

@markmandel markmandel added kind/bug These are bugs. area/user-experience Pertaining to developers trying to use Agones, e.g. SDK, installation, etc labels May 26, 2021
@google-cla google-cla bot added the cla: yes label May 26, 2021
@markmandel
Copy link
Member Author

Testing with kubectl as well:

$ kubectl -v 9 create -f ./examples/simple-game-server/gameserverallocation.yaml -o yaml
....
I0526 20:22:28.749263    1257 request.go:1068] Request Body: {"apiVersion":"allocation.agones.dev/v1","kind":"GameServerAllocation","metadata":{"namespace":"default"},"spec":{"required":{"matchLabels":{"agones.dev/fleet":"simple-game-server"}}}}
I0526 20:22:28.749302    1257 round_trippers.go:424] curl -k -v -XPOST  -H "Content-Type: application/json" -H "User-Agent: kubectl/v1.18.15 (linux/amd64) kubernetes/73dd5c8" -H "Accept: application/json" 'https://34.83.43.189/apis/allocation.agones.dev/v1/namespaces/default/gameserverallocations'
I0526 20:22:28.911903    1257 round_trippers.go:444] POST https://34.83.43.189/apis/allocation.agones.dev/v1/namespaces/default/gameserverallocations 201 Created in 162 milliseconds

You can see the 201 on the last line 🥳

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: 55ecdd05-a60f-4170-94f7-8c959dfcbbb1

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/2110/head:pr_2110 && git checkout pr_2110
  • helm install ./install/helm/agones --namespace agones-system --name agones --set agones.image.tag=1.15.0-98ead5a

The standard for CRD creation is to return a HTTP 201 response. The Go
client is more flexible and was happy with a 200 response, but the C#
client will error out if anything but a 201 response.

This fixes things so we send the correct HTTP response code when
creating a GameServerAllocation.

Closes googleforgames#2108
@markmandel markmandel force-pushed the bug/allocation-status branch from 98ead5a to 04cd13b Compare May 26, 2021 22:13
@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: f37838a2-d591-45e7-85d9-387c4d7eb847

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/2110/head:pr_2110 && git checkout pr_2110
  • helm install ./install/helm/agones --namespace agones-system --name agones --set agones.image.tag=1.15.0-04cd13b

@@ -103,6 +103,7 @@ func TestControllerAllocator(t *testing.T) {
rec := httptest.NewRecorder()
err = c.processAllocationRequest(ctx, rec, r, "default")
assert.NoError(t, err)
assert.Equal(t, http.StatusCreated, rec.Code)
Copy link
Member

Choose a reason for hiding this comment

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

We shouldn't block this bug fix merging, but it seems like we have a test that covers the other two case statements (using the metav1 status and returning a http.StatusOK).

@roberthbailey roberthbailey merged commit 9bdf7a3 into googleforgames:main May 27, 2021
@google-oss-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: markmandel, roberthbailey

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:
  • OWNERS [markmandel,roberthbailey]

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

@markmandel markmandel deleted the bug/allocation-status branch May 27, 2021 17:47
@sawagh sawagh added this to the 1.15.0 milestone Jun 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved area/user-experience Pertaining to developers trying to use Agones, e.g. SDK, installation, etc cla: yes kind/bug These are bugs. lgtm size/S
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Creating a GameServerAllocation returns a 200 Ok instead of a 201 Created
5 participants