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

Refactor gameserverallocations to its components #1015

Merged
merged 1 commit into from
Aug 28, 2019

Conversation

pooneh-m
Copy link
Contributor

@pooneh-m pooneh-m commented Aug 27, 2019

gameserverallocations is a module with multiple independent responsibilities.

  1. Controller which implements the APIServer extension
  2. Allocation handler which allocate from the pool of ready game servers and does batch allocation
  3. Cache handler which handles the pool of game servers that is cached
  4. Latency recorder

This refactoring does not change any logic and only moves the code around to its rightful modules to simplify and also to make the allocation library reusable by agones-allocator service to address #1018 with parent issue #597.

@agones-bot
Copy link
Collaborator

Build Failed 😱

Build Id: 6057f975-d3ee-4c27-b831-96ff21bd081c

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

@agones-bot
Copy link
Collaborator

Build Failed 😱

Build Id: 4121a51b-3362-4b6d-9b67-15ef9f39d592

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

@agones-bot
Copy link
Collaborator

Build Failed 😱

Build Id: 8ecb1c89-26aa-4dce-9c5b-9028aceb16ce

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

@pooneh-m
Copy link
Contributor Author

I am investigating the failures, but please give an early feedback on the refactoring if it makes sense.

@roberthbailey
Copy link
Member

I'll take a look shortly.

@agones-bot
Copy link
Collaborator

Build Failed 😱

Build Id: ce35fa63-351d-4b83-81ce-54bbd78326ad

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

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: be10af58-b2ed-471c-bc2e-a63d4555dc55

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/1015/head:pr_1015 && git checkout pr_1015
  • helm install install/helm/agones --namespace agones-system --name agones --set agones.image.tag=1.0.0-ed813d7

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.

Overall, not seeing any issues here 👍 mostly had some thoughts about naming, and maybe cleanup a small piece of previous code.

pkg/gameserverallocations/allocation_handler.go Outdated Show resolved Hide resolved
pkg/gameserverallocations/controller.go Outdated Show resolved Hide resolved
pkg/gameserverallocations/latency_recorder.go Outdated Show resolved Hide resolved
pkg/gameserverallocations/cache_handler.go Outdated Show resolved Hide resolved
pkg/gameserverallocations/cache_handler.go Outdated Show resolved Hide resolved
}

// Enqueue enqueues a game server to be synced. Using queue helps avoiding multiple threads syncing at the same time.
func (c *CacheHandler) Enqueue(gs *agonesv1.GameServer) {
Copy link
Member

Choose a reason for hiding this comment

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

Should we take the opportunity to clean this up a little?

Make this something like EnqueueResync() or similar, that takes no arguments. The code never actually checks the key, so we could pass in an arbitrary string.

Might make more sense semantically. WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm why are we syncing the whole cache and not just the one that is out of sync?

Copy link
Member

Choose a reason for hiding this comment

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

@ilkercelikyilmaz can you provide more context? I believe you wrote this part.

From memory, I think this is used only in a complete "we're no longer sure what's happening, so lets sync everything just in case", such as here

)

// CacheHandler handles the gameserver sync operations for cache
type CacheHandler struct {
Copy link
Member

Choose a reason for hiding this comment

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

Should be call this a ReadyGameServerCache or something similar?

(and maybe the file should be cache.go?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How about ready_gs_cache.go?

Copy link
Member

Choose a reason for hiding this comment

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

That works - I tend to like shorter file names, and since file names in go aren't 1:1 to object definitions (like java), I usually go for something a little less specific if I don't have to.

But I'm not wedded to it - ready_gs_cache.go is fine.

Copy link
Member

Choose a reason for hiding this comment

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

or compromise: ready_cache.go ? 😄

@pooneh-m
Copy link
Contributor Author

Thanks @markmandel for the review. The naming suggestions are great.

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: 98807806-16e4-47be-92d0-138ff13bc729

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/1015/head:pr_1015 && git checkout pr_1015
  • helm install install/helm/agones --namespace agones-system --name agones --set agones.image.tag=1.0.0-1279da3

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.

Approved on my end. If you like the filename change, go ahead, otherwise, merge when ready 👍

@google-oss-robot
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: markmandel, pooneh-m
To complete the pull request process, please assign
You can assign the PR to them by writing /assign in a comment when ready.

The full list of commands accepted by this bot can be found 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

@google-oss-robot
Copy link

New changes are detected. LGTM label has been removed.

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: 1c452e71-a60b-4150-b8fd-0498ed40e31d

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/1015/head:pr_1015 && git checkout pr_1015
  • helm install install/helm/agones --namespace agones-system --name agones --set agones.image.tag=1.0.0-78fd6eb

@pooneh-m pooneh-m merged commit 7b5e618 into googleforgames:master Aug 28, 2019
@markmandel markmandel added this to the 1.0.0 milestone Sep 10, 2019
@markmandel markmandel added the kind/cleanup Refactoring code, fixing up documentation, etc label Sep 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/cleanup Refactoring code, fixing up documentation, etc size/XXL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants