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

Prevent race conditions by syncing cache on new Allocation elements #780

Merged

Conversation

markmandel
Copy link
Member

Added cache.InformerSynced members for the new resources that are worked on within this code for the multicluster allocations, to ensure they aren't empty values on controller startup.

Also applying these at the test level, so we don't get random test flakiness due to cache's not being populated in time for the test to run.

@markmandel markmandel added kind/bug These are bugs. area/tests Unit tests, e2e tests, anything to make sure things don't break labels May 17, 2019
@markmandel markmandel added this to the 0.11.0 milestone May 17, 2019
@markmandel
Copy link
Member Author

/cc @pooneh-m fyi.

Apologies for not picking this up in code review 😞

Please let me know if you need to me explain what is going on here 👍

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: a37d64e9-010c-4755-9ef3-80455b67742c

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/GoogleCloudPlatform/agones.git pull/780/head:pr_780 && git checkout pr_780
  • helm install install/helm/agones --namespace agones-system --name agones --set agones.image.tag=0.10.0-2e633e4

Copy link
Contributor

@pooneh-m pooneh-m 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 catching that.

@@ -75,7 +75,7 @@ func TestControllerAllocationHandler(t *testing.T) {
return true, gs, nil
})

stop, cancel := agtesting.StartInformers(m)
stop, cancel := agtesting.StartInformers(m, c.gameServerSynced)
Copy link
Contributor

Choose a reason for hiding this comment

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

if the controller has the WaitForCacheSync, is it really needed to call StartInformers that does the same thing (e.g. calling WaitForCacheSync)

Copy link
Member Author

Choose a reason for hiding this comment

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

The WaitforcacheSync is called in the controller .Run() command - so just instantiating the controller doesn't fire the WaitforcacheSync.

And in tests (I've found anyway), you often don't want everything that happens inside the Run() command to fire.

This was following the patterns of the sample controller

@pooneh-m
Copy link
Contributor

LGTM

@@ -893,7 +893,7 @@ func TestMultiClusterAllocationFromRemote(t *testing.T) {
return true, getTestSecret(secretName, server.TLS.Certificates[0].Certificate[0]), nil
})

stop, cancel := agtesting.StartInformers(m)
stop, cancel := agtesting.StartInformers(m, c.secretSynced)
Copy link
Contributor

Choose a reason for hiding this comment

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

agtesting.StartInformers(m, c.allocationPolicySynced, c.gameServerSynced, c.secretSynced) here and in other places?

Copy link
Member Author

Choose a reason for hiding this comment

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

Nicely spotted! Yep - exactly. Pushing up a change now. 💯

Added cache.InformerSynced members for the new resources that are
worked on within this code for the multicluster allocations, to ensure
they aren't empty values on controller startup.

Also applying these at the test level, so we don't get random test
flakiness due to cache's not being populated in time for the test to
run.
@markmandel markmandel force-pushed the bug/gameserverallocations-race branch from 2e633e4 to 2d5219d Compare May 18, 2019 04:02
@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: 077c52d7-a2e3-4057-b168-ff9a326e0666

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/GoogleCloudPlatform/agones.git pull/780/head:pr_780 && git checkout pr_780
  • helm install install/helm/agones --namespace agones-system --name agones --set agones.image.tag=0.10.0-2d5219d

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: eeeaef75-d1d9-46e5-a56f-048718a230b2

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/GoogleCloudPlatform/agones.git pull/780/head:pr_780 && git checkout pr_780
  • helm install install/helm/agones --namespace agones-system --name agones --set agones.image.tag=0.10.0-480453d

@markmandel markmandel merged commit 6683b41 into googleforgames:master May 21, 2019
@markmandel markmandel deleted the bug/gameserverallocations-race branch May 21, 2019 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/tests Unit tests, e2e tests, anything to make sure things don't break kind/bug These are bugs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants