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

Creating a FleetAllocation allocated a GameServer from a Fleet #193

Merged

Conversation

markmandel
Copy link
Member

This implements the FleetAllocation CRD, that when created looks at the requested Fleet, and marks one of the GameServers as Allocated (if available) and returns it's value in the FleetAllocation.

This also includes a quickstart and spec for reference as well.

Some refactoring was included in the PR (probably should have been a seperate PR for that).

@markmandel markmandel added the kind/feature New features for Agones label May 1, 2018
@markmandel markmandel added this to the 0.2 milestone May 1, 2018
@@ -169,7 +168,7 @@ func (c *Controller) syncFleet(key string) error {
return errors.Wrapf(err, "error retrieving fleet %s from namespace %s", name, namespace)
}

list, err := c.listGameServerSets(fleet)
list, err := ListGameServerSetsByFleetOwner(c.gameServerSetLister, fleet)
Copy link
Member Author

Choose a reason for hiding this comment

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

@enocom would love to get your opinion on this refactor (implementation here)

There were several places I needed a list type function like this, and wasn't quite sure the best way to do it.

Copy link
Contributor

Choose a reason for hiding this comment

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

See my response below.

@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: 44021edf-184a-4e67-9594-49089cee089c

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

@markmandel markmandel mentioned this pull request May 1, 2018
5 tasks
}

// Validateupdate validates when an update occurs
func (fa *FleetAllocation) Validateupdate(new *FleetAllocation) (bool, []metav1.StatusCause) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nitpick: ValidateUpdate

ErrNoGameServerReady = errors.New("Could not find a Ready GameServer")
)

// Controller is a the GameServerSet controller
Copy link
Collaborator

Choose a reason for hiding this comment

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

FleetAllocation controller

@EricFortin
Copy link
Collaborator

LGTM!

// ListGameServerSetsByFleetOwner lists all the GameServerSets for a given
// Fleet
func ListGameServerSetsByFleetOwner(gameServerSetLister listerv1alpha1.GameServerSetLister, f *stablev1alpha1.Fleet) ([]*stablev1alpha1.GameServerSet, error) {
list, err := gameServerSetLister.List(labels.SelectorFromSet(labels.Set{stablev1alpha1.FleetGameServerSetLabel: f.ObjectMeta.Name}))
Copy link
Contributor

Choose a reason for hiding this comment

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

Based on a cursory reading of the code, I think you could even replace the concrete type *stablev1alpha1.Fleet with a metav1.Object interface. This way, the ListGameServerSetsByFleetOwner function might enjoy an even wider usage.

Copy link
Contributor

Choose a reason for hiding this comment

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

If you use the metav1.Object interface here, then the name lookup becomes f.GetName() as with the lookup below.

Copy link
Member Author

Choose a reason for hiding this comment

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

So I personally wasn't concerned with the type - since in this case, I really only want Fleets to be passed in. So using a Fleet as the type signature makes sense, at least in my mind - it should be restrictive.

I guess my concern was more around passing in the Lister to the function as an argument (rather than somehow creating another data structure with methods). This felt more lightweight, but was wondering if you saw any issues there?

Copy link
Contributor

Choose a reason for hiding this comment

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

I've seen that pattern in some object-oriented code, but I'm having a hard time remembering what the pattern might be called. It seems entirely reasonable to me.

Copy link
Member Author

Choose a reason for hiding this comment

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

SGTM! Thanks for the sanity check.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it's basically a form of double dispatch.

This implements the FleetAllocation CRD, that when created
looks at the requested Fleet, and marks one of the
GameServers as Allocated (if available) and returns it's value
in the FleetAllocation.

This also includes a quickstart and spec for reference as well.

Some refactoring was included in the PR (probably should have been
a seperate PR for that).
@markmandel markmandel force-pushed the feature/fleet-allocation branch from 7a4079a to 762b537 Compare May 2, 2018 01:18
@agones-bot
Copy link
Collaborator

Build Succeeded 👏

Build Id: f4ab7fcb-c6b8-46c2-982a-42ad32ea92b4

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

@markmandel markmandel merged commit c6ab6b0 into googleforgames:master May 2, 2018
@markmandel markmandel deleted the feature/fleet-allocation branch May 2, 2018 14:42
@agones-bot
Copy link
Collaborator

Build Failed 😱

Build Id: 1c628f59-78a4-42f7-b8d7-23c553eebd76

Build Logs
starting build "1c628f59-78a4-42f7-b8d7-23c553eebd76"

FETCHSOURCE
Initialized empty Git repository in /workspace/.git/
From https://source.developers.google.com/p/agones-images/r/agones
 * branch            762b537bf1af3c66e36b82a9124d6ff51b412eaf -> FETCH_HEAD
HEAD is now at 762b537 Creating a FleetAllocation allocated a GameServer from a Fleet
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  131.1MB

Step #1: Step 1/3 : FROM gcr.io/cloud-builders/docker
Step #1:  ---> e0788ef25586
Step #1: Step 2/3 : RUN apt-get install make
Step #1:  ---> Running in 8cbf28ad28e0
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 33 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 (231 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 8cbf28ad28e0
Step #1:  ---> 54a66cef630d
Step #1: Step 3/3 : ENTRYPOINT ["/usr/bin/make"]
Step #1:  ---> Running in 21f011225e87
Step #1: Removing intermediate container 21f011225e87
Step #1:  ---> 19132a74ff39
Step #1: Successfully built 19132a74ff39
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:e52ce865fb && docker tag gcr.io/agones-images/agones-build:e52ce865fb agones-build:e52ce865fb
Step #2: e52ce865fb: Pulling from agones-images/agones-build
Step #2: c73ab1c6897b: Pulling fs layer
Step #2: 3091fac74ac3: Pulling fs layer
Step #2: 32ec8f15f1df: Pulling fs layer
Step #2: 8a19269d40b4: Pulling fs layer
Step #2: e6425ad9525a: Pulling fs layer
Step #2: 16df2efc4858: Pulling fs layer
Step #2: 2b2d73ab4219: Pulling fs layer
Step #2: 5f2d382df949: Pulling fs layer
Step #2: 5b739d0afd39: Pulling fs layer
Step #2: eb921739ae12: Pulling fs layer
Step #2: 2022ec0c796a: Pulling fs layer
Step #2: 3ee570d976e5: Pulling fs layer
Step #2: 59f7198d9c1c: Pulling fs layer
Step #2: 08501ff593d9: Pulling fs layer
Step #2: a5d32e6825a2: Pulling fs layer
Step #2: 42602390dd8d: Pulling fs layer
Step #2: 8a19269d40b4: Waiting
Step #2: e6425ad9525a: Waiting
Step #2: 16df2efc4858: Waiting
Step #2: 2b2d73ab4219: Waiting
Step #2: 5f2d382df949: Waiting
Step #2: 5b739d0afd39: Waiting
Step #2: eb921739ae12: Waiting
Step #2: 2022ec0c796a: Waiting
Step #2: 3ee570d976e5: Waiting
Step #2: 59f7198d9c1c: Waiting
Step #2: 08501ff593d9: Waiting
Step #2: a5d32e6825a2: Waiting
Step #2: 42602390dd8d: Waiting
Step #2: c73ab1c6897b: Verifying Checksum
Step #2: c73ab1c6897b: Download complete
Step #2: 8a19269d40b4: Verifying Checksum
Step #2: 8a19269d40b4: Download complete
Step #2: 3091fac74ac3: Verifying Checksum
Step #2: 3091fac74ac3: Download complete
Step #2: 16df2efc4858: Verifying Checksum
Step #2: 16df2efc4858: Download complete
Step #2: e6425ad9525a: Verifying Checksum
Step #2: e6425ad9525a: Download complete
Step #2: 5f2d382df949: Verifying Checksum
Step #2: 5f2d382df949: Download complete
Step #2: 5b739d0afd39: Verifying Checksum
Step #2: 5b739d0afd39: Download complete
Step #2: 2b2d73ab4219: Verifying Checksum
Step #2: 2b2d73ab4219: Download complete
Step #2: eb921739ae12: Verifying Checksum
Step #2: eb921739ae12: Download complete
Step #2: 3ee570d976e5: Verifying Checksum
Step #2: 3ee570d976e5: Download complete
Step #2: 59f7198d9c1c: Verifying Checksum
Step #2: 59f7198d9c1c: Download complete
Step #2: 2022ec0c796a: Verifying Checksum
Step #2: 2022ec0c796a: Download complete
Step #2: 08501ff593d9: Verifying Checksum
Step #2: 08501ff593d9: Download complete
Step #2: a5d32e6825a2: Verifying Checksum
Step #2: a5d32e6825a2: Download complete
Step #2: 42602390dd8d: Verifying Checksum
Step #2: 42602390dd8d: Download complete
Step #2: 32ec8f15f1df: Verifying Checksum
Step #2: 32ec8f15f1df: Download complete
Step #2: c73ab1c6897b: Pull complete
Step #2: 3091fac74ac3: Pull complete
Step #2: 32ec8f15f1df: Pull complete
Step #2: 8a19269d40b4: Pull complete
Step #2: e6425ad9525a: Pull complete
Step #2: 16df2efc4858: Pull complete
Step #2: 2b2d73ab4219: Pull complete
Step #2: 5f2d382df949: Pull complete
Step #2: 5b739d0afd39: Pull complete
Step #2: eb921739ae12: Pull complete
Step #2: 2022ec0c796a: Pull complete
Step #2: 3ee570d976e5: Pull complete
Step #2: 59f7198d9c1c: Pull complete
Step #2: 08501ff593d9: Pull complete
Step #2: a5d32e6825a2: Pull complete
Step #2: 42602390dd8d: Pull complete
Step #2: Digest: sha256:0344289d4121c2024d5b7d8790a8f3a5043b2149c0632928a2d4d9d0b8473f24
Step #2: Status: Downloaded newer image for gcr.io/agones-images/agones-build:e52ce865fb
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 -w /go/src/agones.dev/agones  agones-build:e52ce865fb bash -c \
Step #3: 	"/root/gen-lint-exclude.sh && gometalinter --config .exclude.gometalinter.json --deadline 100s -t --skip vendor ./..."
Step #3: WARNING: deadline exceeded by linter megacheck (try increasing --deadline)
Step #3: WARNING: deadline exceeded by linter vet (try increasing --deadline)
Step #3: make: *** [lint] Error 2
Step #3: Makefile:136: recipe for target 'lint' failed
Finished Step #3
ERROR
ERROR: build step 3 "make-docker" failed: exit status 2

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.

4 participants