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

Graduate StateAllocationFilter to Stable #3308

Merged
merged 13 commits into from
Aug 11, 2023

Conversation

Kalaiselvi84
Copy link
Contributor

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
/kind release

What this PR does / Why we need it:

Which issue(s) this PR fixes:

Closes #

Special notes for your reviewer:

@agones-bot
Copy link
Collaborator

Build Failed 😱

Build Id: e1b5fa03-59a6-43d3-bd51-e4ca4186eda4

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

@agones-bot
Copy link
Collaborator

Build Failed 😱

Build Id: db01691e-0ab3-48ff-a0bc-5fc031a97540

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

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.

Great start! Gave some comments on some general cleanup, and also on why those unit tests are failing.

examples/gameserverallocation-deprecated.yaml Show resolved Hide resolved
examples/gameserverallocation.yaml Show resolved Hide resolved
@@ -45,7 +45,6 @@ The current set of `alpha` and `beta` feature gates:
| [GameServer Stable Network ID]({{% ref "/docs/Reference/gameserver.md#stable-network-id" %}}) | `PodHostname` | Enabled | `Beta` | 1.32.0 |
| [Reset Metric Export on Fleet / Autoscaler deletion]({{% relref "./metrics.md#dropping-metric-labels" %}}) | `ResetMetricsOnDelete` | Enabled | `Beta` | 1.32.0 |
| [Split `agones-controller` ](https://github.com/googleforgames/agones/issues/2797) | `SplitControllerAndExtensions` | Enabled | `Beta` | 1.32.0 |
| [GameServer state filtering on GameServerAllocations](https://github.com/googleforgames/agones/issues/1239) | `StateAllocationFilter` | Enabled | `Beta` | 1.26.0 |
Copy link
Member

Choose a reason for hiding this comment

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

We'll need to use a feature shortcode for the documentation please.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This line has been added in the expiryVersion shortcode and removed it from the publishVersion shortcode.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we also delete line 34 | [GameServer state filtering on GameServerAllocations](https://github.com/googleforgames/agones/issues/1239) | StateAllocationFilter | Enabled |Beta | 1.26.0 |?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This line is in expiryVersion of feature shortcode and lines in expiryVersion shortcode will be removed during the release. Could you please correct me if I am wrong?

@@ -500,13 +480,10 @@ func TestAllocationCacheCompareGameServers(t *testing.T) {
}
}

func TestAllocatorRunCacheSyncFeatureStateAllocationFilter(t *testing.T) {
func TestAllocatorRunCacheSync(t *testing.T) {
t.Parallel()

// TODO(markmandel): When this feature gets promoted to stable, replace test TestAllocatorRunCacheSync below with this test.
Copy link
Member

Choose a reason for hiding this comment

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

We can drop the TODO as well here please, since we did the replacement 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done!

- matchLabels:
game: my-game
matchExpressions:
- {key: tier, operator: In, values: [cache]}
Copy link
Member

Choose a reason for hiding this comment

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

I might be not seeing something, but shouldn't gameServerState be in here somewhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added it along with description

@@ -216,7 +216,7 @@ func TestConvertAllocationRequestToGameServerAllocation(t *testing.T) {
},
{
name: "all fields are set",
features: fmt.Sprintf("%s=false&%s=false&%s=false", runtime.FeaturePlayerAllocationFilter, runtime.FeatureStateAllocationFilter, runtime.FeatureCountsAndLists),
Copy link
Member

Choose a reason for hiding this comment

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

This test will need to be changed, since it had TestConvertAllocationRequestToGameServerAllocation set to false, so it's expecting a nil GameServer.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do I need to include something like the below code snippet?
{
name: "nil object",
in: nil,
want: nil,
},

Copy link
Member

Choose a reason for hiding this comment

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

Here is the test implementation:

for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
runtime.FeatureTestMutex.Lock()
defer runtime.FeatureTestMutex.Unlock()
require.NoError(t, runtime.ParseFeatures(tc.features))
out := ConvertAllocationRequestToGSA(tc.in)
assert.Equal(t, tc.want, out, "mismatch with want after conversion: \"%s\"", tc.name)

This is a really good example of Go table driven tests: https://dave.cheney.net/2019/05/07/prefer-table-driven-tests

Have a look, lemme know if you have questions, and we can go from there 👍🏻

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The tests were failing with GameServerState: nil, but they succeeded after updating it to GameServerState: &ready

@@ -366,7 +366,7 @@ func TestConvertAllocationRequestToGameServerAllocation(t *testing.T) {
},
{
name: "empty fields to GSA with selectors fields",
features: fmt.Sprintf("%s=false&%s=false&%s=false", runtime.FeaturePlayerAllocationFilter, runtime.FeatureStateAllocationFilter, runtime.FeatureCountsAndLists),
Copy link
Member

Choose a reason for hiding this comment

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

This test will need to be changed, since it had TestConvertAllocationRequestToGameServerAllocation set to false, so it's expecting a nil GameServer.

@agones-bot
Copy link
Collaborator

Build Failed 😱

Build Id: 8cb07a2a-df82-44cf-9edc-4fae8d21ad5e

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

@agones-bot
Copy link
Collaborator

Build Failed 😱

Build Id: cb36d2cd-cae1-4cf6-a9eb-ab9d0d51ad41

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

@@ -127,7 +127,7 @@ func TestFindGameServerForAllocationPacked(t *testing.T) {
assert.Equal(t, ErrNoGameServer, err)
assert.Nil(t, gs)
},
features: fmt.Sprintf("%s=false&%s=false", runtime.FeaturePlayerAllocationFilter, runtime.FeatureStateAllocationFilter),
Copy link
Collaborator

Choose a reason for hiding this comment

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

You can delete this entire "one label" test, as it is only passing when FeatureStateAllocationFilter=False.

(The test below "one label with player state (StateAllocationFilter)" is for when StateAllocationFilter=True.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Deleted the "one label" test.

@@ -127,7 +127,7 @@ func TestFindGameServerForAllocationPacked(t *testing.T) {
assert.Equal(t, ErrNoGameServer, err)
assert.Nil(t, gs)
},
features: fmt.Sprintf("%s=false&%s=false", runtime.FeaturePlayerAllocationFilter, runtime.FeatureStateAllocationFilter),
features: fmt.Sprintf("%s=false", runtime.FeaturePlayerAllocationFilter),
},
"one label with player state (StateAllocationFilter)": {
// nolint: dupl
Copy link
Collaborator

Choose a reason for hiding this comment

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

You can also delete this line // nolint: dupl once the "one label" test is deleted.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Deleted // nolint: dupl line

@@ -278,7 +278,7 @@ func TestFindGameServerForAllocationPacked(t *testing.T) {
assert.Equal(t, gs, list[index])
assert.Equal(t, agonesv1.GameServerStateReady, gs.Status.State)
},
features: fmt.Sprintf("%s=false&%s=false", runtime.FeaturePlayerAllocationFilter, runtime.FeatureStateAllocationFilter),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Change line 273 from require.Len(t, list, 4) to require.Len(t, list, 8).

The previous StateAllocationFilter=false used a cache with matcher gameserverallocations.readyGameServerMatcher which only returns the ready gameservers. The current StateAllocationFilter=true uses a cache with matcher gameserverallocations.readyOrAllocatedGameServerMatcher which returns ready or allocated game servers.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!
I have made changes to a few more lines that were indicated in the error log.

@igooch
Copy link
Collaborator

igooch commented Aug 9, 2023

You'll also need to navigate to agones/build and then run make gen-api-docs since some of the code comments have changed.

I usually do this (and any other generated files) as unique commit within the PR just in case they need to be dropped and regenerated later.

@agones-bot
Copy link
Collaborator

Build Failed 😱

Build Id: 078051e6-f288-43a4-b986-aa1b1c016edf

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 Aug 9, 2023
@Kalaiselvi84
Copy link
Contributor Author

make gen-api-docs

This command updated aones_crd_api_reference.html file

@agones-bot
Copy link
Collaborator

Build Failed 😱

Build Id: 551cca44-b99f-44b1-b1dd-60ad1da105b7

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

@agones-bot
Copy link
Collaborator

Build Failed 😱

Build Id: 4c4bd9b8-69cd-4508-947d-893827fd7b61

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

@igooch
Copy link
Collaborator

igooch commented Aug 9, 2023

File agones/pkg/gameserverallocations/allocator_test.go has a remaining reference to the FeatureStateAllocationFilter.

@Kalaiselvi84
Copy link
Contributor Author

File agones/pkg/gameserverallocations/allocator_test.go has a remaining reference to the FeatureStateAllocationFilter.

Excluded the FeatureStateAllocationFilter from agones/pkg/gameserverallocations/allocator_test.go

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: 659baa80-6d75-4414-8b42-84d96e54cfc2

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/3308/head:pr_3308 && git checkout pr_3308
  • 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.34.0-dev-e198445-amd64

@Kalaiselvi84
Copy link
Contributor Author

Please find the error log here. There are 4 test cases failing, but the build has succeeded.

@markmandel
Copy link
Member

Honestly, I don't usually run the full suite of e2e tests locally - it takes too long, and there are usually some setup that make differ slightly than the prod testing setup (might as well make other computers do all the work while doing other things!).

I usually just focus on https://github.com/googleforgames/agones/blob/main/build/README.md#running-individual-end-to-end-tests if there are specific tests I think are very relevant to what I'm working on or are failing in Cloud Build.

So if you are passing in Cloud Build - you are passing!

@@ -201,7 +201,7 @@ func TestAllocatorWithSelectors(t *testing.T) {
helper.ValidateAllocatorResponse(t, response)

// let's do a re-allocation
if runtime.FeatureEnabled(runtime.FeatureStateAllocationFilter) && runtime.FeatureEnabled(runtime.FeaturePlayerAllocationFilter) {
if runtime.FeatureEnabled(runtime.FeaturePlayerAllocationFilter) {
logrus.Info("testing state allocation filter")
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should probably pull the state allocation filter tests out of this if runtime.FeatureEnabled(runtime.FeaturePlayerAllocationFilter) block.

@@ -106,7 +106,7 @@ func TestAllocatorWithDeprecatedRequired(t *testing.T) {
helper.ValidateAllocatorResponse(t, response)

// let's do a re-allocation
if runtime.FeatureEnabled(runtime.FeatureStateAllocationFilter) && runtime.FeatureEnabled(runtime.FeaturePlayerAllocationFilter) {
if runtime.FeatureEnabled(runtime.FeaturePlayerAllocationFilter) {
logrus.Info("testing state allocation filter")
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should probably pull the state allocation filter tests out of this if runtime.FeatureEnabled(runtime.FeaturePlayerAllocationFilter) block.

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: 56a46d89-1850-43cb-b874-5b723796c97a

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/3308/head:pr_3308 && git checkout pr_3308
  • 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.34.0-dev-61dab35-amd64

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: ceb462f7-2200-4503-8d4b-d8ecdd40a0dc

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/3308/head:pr_3308 && git checkout pr_3308
  • 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.34.0-dev-b43eb8d-amd64

@Kalaiselvi84
Copy link
Contributor Author

there are usually some setup that make differ slightly than the prod testing setup

In this case, I will move the PR to "Ready for Review"

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.

This LGTM! @igooch did you want to take another pass?

Copy link
Collaborator

@igooch igooch left a comment

Choose a reason for hiding this comment

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

LGTM

@google-oss-prow
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: igooch, Kalaiselvi84, 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 merged commit 62d30b3 into googleforgames:main Aug 11, 2023
3 checks passed
@Kalaiselvi84 Kalaiselvi84 deleted the pr_3096 branch March 15, 2024 01:14
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.

4 participants