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

GameServerSet Implementation #156

Merged
merged 1 commit into from
Apr 10, 2018

Conversation

markmandel
Copy link
Member

GameServerSets are the basic building block for Fleets. They allow for creating a set of GameServers that can be scaled up and down in size, while also being aware of Allocated GameServers and ensuring they don't get deleted.

GameServerSets will be allow Fleet migrations to occur, similarly to how ReplicaSets allow Deployments to migrate one image type to another.

This has not been formally documented, as this will likely be an internal CRD, and not (widely) used externally.

Parent ticket: #70

@markmandel markmandel added the kind/feature New features for Agones label Apr 3, 2018
@markmandel markmandel added this to the 0.2 milestone Apr 3, 2018
@markmandel
Copy link
Member Author

/cc @ianlewis if you also want to take a look.

If anyone has a better name than GameServerSet, I'm also all ears. I can't reuse ReplicaSet because it would conflict with kubectl so 🤷‍♂️

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: 62d85413-adb8-43f4-906c-aed851ee0d28

The following development artifacts have been built, and will exist for the next 30 days:


logger.Info("Shut down gameserver controller")
<-stop
logger.Info("Shut down agones controller")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nitpick: controllers

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

c.recorder.Eventf(gss, corev1.EventTypeNormal, "SuccessfulDelete", "Deleted GameServer: %s", gs.ObjectMeta.Name)
count++
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

What happens if they are all allocated? Will this re-queue the sync event to be processed later on?

Copy link
Member Author

Choose a reason for hiding this comment

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

If they are allocated, the event handler above will watch for when the GameServer is deleted for this GameServerSet, and when it catches that event, it will queue the owning GameServerSet to be processed again, and make sure it's at the right number.

@markmandel
Copy link
Member Author

/cc @enocom would also love for you to (particularly) look at the changes I made to main.go to facilitate multiple controllers. See if you see any issues.

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: e9546851-b2a2-4a66-ba44-c9f88497c120

The following development artifacts have been built, and will exist for the next 30 days:

@@ -128,7 +129,8 @@ func main() {
agonesInformerFactory := externalversions.NewSharedInformerFactory(agonesClient, 30*time.Second)
kubeInformationFactory := informers.NewSharedInformerFactory(kubeClient, 30*time.Second)

c := gameservers.NewController(wh, health, minPort, maxPort, sidecarImage, alwaysPullSidecar, kubeClient, kubeInformationFactory, extClient, agonesClient, agonesInformerFactory)
gsController := gameservers.NewController(wh, health, minPort, maxPort, sidecarImage, alwaysPullSidecar, kubeClient, kubeInformationFactory, extClient, agonesClient, agonesInformerFactory)
gssController := gameserversets.NewController(wh, kubeClient, extClient, agonesClient, agonesInformerFactory)
Copy link
Contributor

Choose a reason for hiding this comment

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

@markmandel The one letter difference between variable names is easy to miss. How about gs and gsSet or something that is easier to parse quickly?

Copy link
Member Author

Choose a reason for hiding this comment

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

I like gsSet better. I'm actually going to change that across the whole codebase. I've had issues writing this mixing up gs and gss and it took me ages to fix the bugs!

@enocom
Copy link
Contributor

enocom commented Apr 4, 2018

Small nitpick on variable names in main.go. Otherwise, LGTM.

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: 335365f9-2c98-4792-8ac4-03f4c7d4be98

The following development artifacts have been built, and will exist for the next 30 days:

@markmandel markmandel mentioned this pull request Apr 4, 2018
5 tasks
@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: 164ae42d-0501-47f1-90e9-1f1844709886

The following development artifacts have been built, and will exist for the next 30 days:

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: a376d314-3a0b-431e-a57b-9dfa5d5b9b77

The following development artifacts have been built, and will exist for the next 30 days:

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: f74aca98-186b-4602-b38f-7e72774b6d84

The following development artifacts have been built, and will exist for the next 30 days:

@agones-bot
Copy link
Collaborator

Build Failed 😱

Build Id: 6aea76ff-2017-4b2b-aef1-10da960c9837

Build Logs
starting build "6aea76ff-2017-4b2b-aef1-10da960c9837"

FETCHSOURCE
Initialized empty Git repository in /workspace/.git/
From https://source.developers.google.com/p/agones-images/r/agones
 * branch            f021e4b28480bd36aa19e95972ae94fa254252fa -> FETCH_HEAD
HEAD is now at f021e4b GameServerSet Implementation
BUILD
Starting Step #0
Step #0: Already have image (with digest): ubuntu
Finished Step #0
Starting Step #1
Step #1: Already have image (with digest): gcr.io/cloud-builders/docker
Step #1: Sending build context to Docker daemon  130.8MB

Step #1: Step 1/3 : FROM gcr.io/cloud-builders/docker
Step #1:  ---> 1cb57e1319cf
Step #1: Step 2/3 : RUN apt-get install make
Step #1:  ---> Running in 16d4efbbd9c3
Step #1: Reading package lists...
Step #1: Building dependency tree...
Step #1: Reading state information...
Step #1: Suggested packages:
Step #1:   make-doc
Step #1: The following NEW packages will be installed:
Step #1:   make
Step #1: 0 upgraded, 1 newly installed, 0 to remove and 29 not upgraded.
Step #1: Need to get 151 kB of archives.
Step #1: After this operation, 365 kB of additional disk space will be used.
Step #1: Get:1 http://archive.ubuntu.com/ubuntu xenial/main amd64 make amd64 4.1-6 [151 kB]
Step #1: �[91mdebconf: unable to initialize frontend: Dialog
Step #1: �[0m�[91mdebconf: (TERM is not set, so the dialog frontend is not usable.)
Step #1: �[0m�[91mdebconf: falling back to frontend: Readline
Step #1: �[0m�[91mdebconf: unable to initialize frontend: Readline
Step #1: �[0m�[91mdebconf: (This frontend requires a controlling tty.)
Step #1: �[0m�[91mdebconf: falling back to frontend: Teletype
Step #1: �[0m�[91mdpkg-preconfigure: unable to re-open stdin: 
Step #1: �[0mFetched 151 kB in 0s (189 kB/s)
Step #1: Selecting previously unselected package make.
Step #1: (Reading database ... 
(Reading database ... 5%
(Reading database ... 10%
(Reading database ... 15%
(Reading database ... 20%
(Reading database ... 25%
(Reading database ... 30%
(Reading database ... 35%
(Reading database ... 40%
(Reading database ... 45%
(Reading database ... 50%
(Reading database ... 55%
(Reading database ... 60%
(Reading database ... 65%
(Reading database ... 70%
(Reading database ... 75%
(Reading database ... 80%
(Reading database ... 85%
(Reading database ... 90%
(Reading database ... 95%
(Reading database ... 100%
(Reading database ... 11239 files and directories currently installed.)
Step #1: Preparing to unpack .../archives/make_4.1-6_amd64.deb ...
Step #1: Unpacking make (4.1-6) ...
Step #1: Setting up make (4.1-6) ...
Step #1: Removing intermediate container 16d4efbbd9c3
Step #1:  ---> f68c6aaa1d9a
Step #1: Step 3/3 : ENTRYPOINT ["/usr/bin/make"]
Step #1:  ---> Running in 1d67840db123
Step #1: Removing intermediate container 1d67840db123
Step #1:  ---> 79cdecbc84b3
Step #1: Successfully built 79cdecbc84b3
Step #1: Successfully tagged make-docker:latest
Finished Step #1
Starting Step #2
Step #2: Already have image: make-docker
Step #2: docker pull gcr.io/agones-images/agones-build:9b34ffcea7 && docker tag gcr.io/agones-images/agones-build:9b34ffcea7 agones-build:9b34ffcea7
Step #2: 9b34ffcea7: Pulling from agones-images/agones-build
Step #2: 723254a2c089: Pulling fs layer
Step #2: ec2377dbc043: Pulling fs layer
Step #2: f4e57b1d42c5: Pulling fs layer
Step #2: e990dc81e6d1: Pulling fs layer
Step #2: 7e20796203b0: Pulling fs layer
Step #2: 6d0012116885: Pulling fs layer
Step #2: f31331557647: Pulling fs layer
Step #2: 817c386869b7: Pulling fs layer
Step #2: 15f2d99a54e5: Pulling fs layer
Step #2: 109f3833b328: Pulling fs layer
Step #2: c1ebd13896d8: Pulling fs layer
Step #2: 26a535b3e9a9: Pulling fs layer
Step #2: 7d15a612c64a: Pulling fs layer
Step #2: e990dc81e6d1: Waiting
Step #2: 7e20796203b0: Waiting
Step #2: 6d0012116885: Waiting
Step #2: f31331557647: Waiting
Step #2: 817c386869b7: Waiting
Step #2: 15f2d99a54e5: Waiting
Step #2: 109f3833b328: Waiting
Step #2: c1ebd13896d8: Waiting
Step #2: 26a535b3e9a9: Waiting
Step #2: 7d15a612c64a: Waiting
Step #2: 723254a2c089: Verifying Checksum
Step #2: 723254a2c089: Download complete
Step #2: e990dc81e6d1: Verifying Checksum
Step #2: e990dc81e6d1: Download complete
Step #2: ec2377dbc043: Verifying Checksum
Step #2: ec2377dbc043: Download complete
Step #2: 6d0012116885: Verifying Checksum
Step #2: 6d0012116885: Download complete
Step #2: 723254a2c089: Pull complete
Step #2: f31331557647: Verifying Checksum
Step #2: f31331557647: Download complete
Step #2: 7e20796203b0: Verifying Checksum
Step #2: 7e20796203b0: Download complete
Step #2: 817c386869b7: Verifying Checksum
Step #2: 817c386869b7: Download complete
Step #2: 109f3833b328: Verifying Checksum
Step #2: 109f3833b328: Download complete
Step #2: 15f2d99a54e5: Verifying Checksum
Step #2: 15f2d99a54e5: Download complete
Step #2: c1ebd13896d8: Verifying Checksum
Step #2: c1ebd13896d8: Download complete
Step #2: 7d15a612c64a: Verifying Checksum
Step #2: 7d15a612c64a: Download complete
Step #2: 26a535b3e9a9: Verifying Checksum
Step #2: 26a535b3e9a9: Download complete
Step #2: f4e57b1d42c5: Verifying Checksum
Step #2: f4e57b1d42c5: Download complete
Step #2: ec2377dbc043: Pull complete
Step #2: f4e57b1d42c5: Pull complete
Step #2: e990dc81e6d1: Pull complete
Step #2: 7e20796203b0: Pull complete
Step #2: 6d0012116885: Pull complete
Step #2: f31331557647: Pull complete
Step #2: 817c386869b7: Pull complete
Step #2: 15f2d99a54e5: Pull complete
Step #2: 109f3833b328: Pull complete
Step #2: c1ebd13896d8: Pull complete
Step #2: 26a535b3e9a9: Pull complete
Step #2: 7d15a612c64a: Pull complete
Step #2: Digest: sha256:7297a3e328a5ac22ac4a100e2d4fb325cab1412650a60abeed9f9cc63114e72e
Step #2: Status: Downloaded newer image for gcr.io/agones-images/agones-build:9b34ffcea7
Finished Step #2
Starting Step #3
Step #3: Already have image: make-docker
Step #3: mkdir -p ~/.kube
Step #3: mkdir -p /workspace/build//.config/gcloud
Step #3: docker run --rm -v /workspace/build//.config/gcloud:/root/.config/gcloud -v ~/.kube:/root/.kube -v /workspace:/go/src/agones.dev/agones agones-build:9b34ffcea7 go test -race agones.dev/agones/...
Step #3: warning: ignoring symlink /go/src/agones.dev/agones/vendor/github.com/prometheus/procfs/fixtures/self
Step #3: ?   	agones.dev/agones	[no test files]
Step #3: # agones.dev/agones/cmd/controller
Step #3: src/agones.dev/agones/cmd/controller/main.go:133:49: not enough arguments in call to gameserversets.NewController
Step #3: 	have (*webhooks.WebHook, *kubernetes.Clientset, *clientset.Clientset, *versioned.Clientset, externalversions.SharedInformerFactory)
Step #3: 	want (*webhooks.WebHook, healthcheck.Handler, kubernetes.Interface, clientset.Interface, versioned.Interface, externalversions.SharedInformerFactory)
Step #3: ok  	agones.dev/agones/pkg/apis/stable/v1alpha1	1.541s
Step #3: ok  	agones.dev/agones/pkg/gameservers	17.467s
Step #3: ok  	agones.dev/agones/pkg/gameserversets	3.458s
Step #3: ok  	agones.dev/agones/pkg/util/crd	4.529s
Step #3: ok  	agones.dev/agones/pkg/util/webhooks	1.657s
Step #3: ok  	agones.dev/agones/pkg/util/workerqueue	2.577s
Step #3: ok  	agones.dev/agones/sdks/go	1.015s
Step #3: make: *** [test] Error 2
Step #3: Makefile:102: recipe for target 'test' failed
Finished Step #3
ERROR
ERROR: build step 3 "make-docker" failed: exit status 2

@markmandel markmandel force-pushed the feature/gameserverset branch 2 times, most recently from 739c4aa to af04795 Compare April 6, 2018 01:51
@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: 7620f887-fbe8-4bff-abe2-7d54fa9a2109

The following development artifacts have been built, and will exist for the next 30 days:

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: bc6b77a2-e97f-4511-8bfb-99e530446c6a

The following development artifacts have been built, and will exist for the next 30 days:

@markmandel
Copy link
Member Author

Blocking #149 (Helm) before merging this - so as to not keep moving the goalposts on what the install.yaml should be.

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: ec7c14eb-2ae9-4b8e-87e5-f9e8be933f2b

The following development artifacts have been built, and will exist for the next 30 days:

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: 96b1ff35-cb75-4279-b938-917ba0d02ec2

The following development artifacts have been built, and will exist for the next 30 days:


# validation for a gameserver spec

{{- define "gameserver.validation" }}
Copy link
Member Author

Choose a reason for hiding this comment

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

@Kuqd @fooock - see any issues with me shifting this validation into a template like this?

Seems like the correct way to do it, but wanted to double check in case you could see anything obviously bad?

Copy link
Contributor

Choose a reason for hiding this comment

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

For me it's ok. Small things:

  • I would add a small documentation above the define, line {{ /* Validation for a gameserver spec .... */ }}
  • Why {{ end - }} instead of {{ - end }} ??
  • Normally these templates are inside the _helpers.tpl file, but by organization, I would leave it like that.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good call on the first two. Done!.

Re:

Normally these templates are inside the _helpers.tpl file, but by organization, I would leave it like that.

So I looked at https://github.com/kubernetes/helm/blob/master/docs/chart_best_practices/templates.md

Template files should have the extension .yaml if they produce YAML output. The extension .tpl may be used for template files that produce no formatted content.

So I made it a .yaml file with an underscore, since it's a pretty big yaml block. WDYT?

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: 29386d56-8281-404a-bc38-235a59c3bb12

The following development artifacts have been built, and will exist for the next 30 days:

GameServerSets are the basic building block for Fleets.
GameServerSets will be allow Fleet migrations to occur, similarly
to how ReplicaSets allow Deployments to migrate one image type
to another.

This has not been formally documented, as this will likely be an
internal CRD, and not (widely) used externally.

Parent ticket: googleforgames#70
@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: e745febb-7e4b-434f-b087-23191b1929cc

The following development artifacts have been built, and will exist for the next 30 days:

@markmandel markmandel merged commit 29957c7 into googleforgames:master Apr 10, 2018
@markmandel markmandel deleted the feature/gameserverset branch April 10, 2018 22:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature New features for Agones
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants