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

GSA: Switch LabelSelector to GameServerSelector #2166

Merged

Conversation

markmandel
Copy link
Collaborator

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:

This embeds the LabelSelector into a GameServerSelector struct, along with the new player and state selector features we need for advanced allocation, and utilising it in the preferred and required sections of a GameServerAllocation.

This means the CRD doesn't change, but the Go api surface does.

This also moves the logic of validation and selection matching into the GameServerSelector so it can be more easily reused.

GameServerAllocations are used pretty much everywhere, so a good chunk of the PR is making that api change.

Which issue(s) this PR fixes:

Work on #1239

Special notes for your reviewer:

Sorry for the chunky PR.

@markmandel markmandel requested a review from roberthbailey July 1, 2021 19:23
@google-cla google-cla bot added the cla: yes label Jul 1, 2021
@markmandel markmandel added kind/feature New features for Agones and removed cla: yes labels Jul 1, 2021
@google-cla google-cla bot added the cla: yes label Jul 1, 2021
@agones-bot
Copy link
Collaborator

Build Failed 😱

Build Id: 743c8ce7-cb7d-4f61-9d8f-0e721e04a6d8

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

@markmandel markmandel force-pushed the feature/gameserverselector branch from 31a1736 to 2e82bdf Compare July 1, 2021 19:49
@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: a833e522-8f50-41d9-bc9e-493784c31cd1

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/2166/head:pr_2166 && git checkout pr_2166
  • helm install ./install/helm/agones --namespace agones-system --name agones --set agones.image.tag=1.16.0-2e82bdf

@roberthbailey
Copy link
Member

This is a large PR... I'll try to get to it before the weekend.

@@ -64,7 +64,7 @@ func ConvertAllocationRequestToGSA(in *pb.AllocationRequest) *allocationv1.GameS
}

if ls := convertLabelSelectorToInternalLabelSelector(in.GetRequiredGameServerSelector()); ls != nil {
gsa.Spec.Required = *ls
gsa.Spec.Required = allocationv1.GameServerSelector{LabelSelector: *ls}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This code will get updates once again once the proto changes, but this allows current functionality to continue working as expected.

@@ -144,5 +265,10 @@ func (gsa *GameServerAllocation) Validate() ([]metav1.StatusCause, bool) {
Message: fmt.Sprintf("Invalid value: %s, value must be either Packed or Distributed", gsa.Spec.Scheduling)})
}

causes, _ = gsa.Spec.Required.Validate("spec.required", causes)
Copy link
Member

Choose a reason for hiding this comment

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

This will overwrite causes if it's non empty. Both here and below you need to append to causes (like is done on line 263).

(update: re-reading the validate function, I can see why this works, but it's really confusing to read. I think it's simpler to have validate not take causes and have this function do the appending).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I agree! I will make this change! Same as comment below 👍🏻

MatchLabels: map[string]string{
"g": "h",
},
}},
Copy link
Member

Choose a reason for hiding this comment

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

What about adding conversion tests for the new fields?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Coming soon to a theatre near you! But once the allocation proto changes are in, because there's nothing to convert things to otherwise.

This embeds the LabelSelector into a GameServerSelector struct, along
with the new player and state selector features we need for advanced
allocation, and utilising it in the `preferred` and `required` sections
of a `GameServerAllocation`.

This means the CRD doesn't change, but the Go api surface does.

This also moves the logic of validation and selection matching into the
GameServerSelector so it can be more easily reused.

GameServerAllocations are used pretty much everywhere, so a good chunk
of the PR is making that api change.

Work on googleforgames#1239
@markmandel markmandel force-pushed the feature/gameserverselector branch from 2e82bdf to 4bce072 Compare July 9, 2021 23:28
@markmandel
Copy link
Collaborator Author

Updated. I'm 50/50 on whether this should be included in this RC or not 🤔

Do we give some end users some pain now in preparation, or wait until the feature is ready to go?

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: 6b522700-32b2-46b9-9452-43189d92aa35

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/2166/head:pr_2166 && git checkout pr_2166
  • helm install ./install/helm/agones --namespace agones-system --name agones --set agones.image.tag=1.16.0-4bce072

@roberthbailey roberthbailey added the feature-freeze-do-not-merge Only eligible to be merged once we are out of feature freeze (next full release) label Jul 13, 2021
@roberthbailey roberthbailey removed the feature-freeze-do-not-merge Only eligible to be merged once we are out of feature freeze (next full release) label Jul 20, 2021
@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: 0f87c2dc-0f98-4f16-b89b-ceab150797c4

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/2166/head:pr_2166 && git checkout pr_2166
  • helm install ./install/helm/agones --namespace agones-system --name agones --set agones.image.tag=1.17.0-e310229

@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

@roberthbailey roberthbailey merged commit 429de93 into googleforgames:main Jul 21, 2021
@markmandel markmandel deleted the feature/gameserverselector branch July 21, 2021 03:06
@roberthbailey roberthbailey added this to the 1.17.0 milestone Jul 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants