Fleet Allocation questions

220 views
Skip to first unread message

Tom Rota

unread,
Sep 4, 2018, 11:28:57 AM9/4/18
to agones-discuss
Hi,

Could anyone tell me what I'm doing wrong while trying to allocate a gameserver?  I'd really appreciate the help.  The environment is Agones from agones-install-0.4.0.rc.zip on GKE installed with Helm. 
There are some more questions inline below.

These are imported:



Constants for namespace, fleetname, and generatename:

const namespace    = "default"
const fleetname    = "somefleet"
const generatename = "somefleet-"


Is this the correct way to use the FleetAllocationsGetter?

    // get a FleetAllocationInterface for the namespace default
    fleetAllocationInterface := agonesClient.StableV1alpha1().FleetAllocations(namespace)


Is this the right way to define the fleet allocation?

    // define the fleet allocation
        fa := &v1alpha1.FleetAllocation{
            ObjectMeta: metav1.ObjectMeta{
                GenerateName: generatename, Namespace: namespace,
              },
                  Spec: v1alpha1.FleetAllocationSpec{FleetName: fleetname},
            }


The call to Create raises "error: "Internal error occurred: Internal error occurred: jsonpatch replace operation does not apply: doc is missing key: /status/GameServer".  Any idea why? 

        // make a new fleet allocation
        newFleetAllocation, err := fleetAllocationInterface.Create(fa)
        if err != nil {
            logger.WithError(err).Fatal("Failed to create fleet allocation for ", fleetname)
        } else {
            logger.Info("Created a fleet allocation for ", fleetname)
        }


Using kubectl create and a yaml file, fleet allocation works as expected.

Thanks in advance!
Tom

Mark Mandel

unread,
Sep 4, 2018, 11:34:19 AM9/4/18
to Tom Rota, agones-discuss
That is strange - not seen that one before.

A few things we can look at:

1) Can you kubectl describe the FleetAllocation that you have created with the api?
2) Can you send through the logs from the controller when you try and allocate (kubectl logs --namespace=agones-system agones-<tabcomplete> - we should be able to see an issue there

Mark

--
You received this message because you are subscribed to the Google Groups "agones-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to agones-discus...@googlegroups.com.
To post to this group, send email to agones-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/agones-discuss/df3e5d3f-b7d3-4dd9-abae-4c0d3d572db9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Tom Rota

unread,
Sep 4, 2018, 12:09:48 PM9/4/18
to agones-discuss
Here's a gameserver that was allocated through the api.  I don't have a FleetAllocation resource...should there be?
Controller logs coming up.

$ kubectl describe gs pymuws-clfzv-q7q5g
Name:         pymuws-clfzv-q7q5g
Namespace:    default
Labels:       stable.agones.dev/gameserverset=pymuws-clfzv
Annotations:  <none>
API Version:  stable.agones.dev/v1alpha1
Kind:         GameServer
Metadata:
  Cluster Name:       
  Creation Timestamp:  2018-09-04T15:43:22Z
  Finalizers:
    stable.agones.dev
  Generate Name:  pymuws-clfzv-
  Generation:     1
  Owner References:
    API Version:           stable.agones.dev/v1alpha1
    Block Owner Deletion:  true
    Controller:            true
    Kind:                  GameServerSet
    Name:                  pymuws-clfzv
    UID:                   40c9d095-b059-11e8-95e0-42010a8e00c1
  Resource Version:        2912
  Self Link:               /apis/stable.agones.dev/v1alpha1/namespaces/default/gameservers/pymuws-clfzv-q7q5g
  UID:                     40d1c258-b059-11e8-95e0-42010a8e00c1
Spec:
  Container:  pymuws-server
  Health:
    Failure Threshold:      3
    Initial Delay Seconds:  60
    Period Seconds:         5
  Ports:
    Container Port:  26000
    Host Port:       7777
    Name:            default
    Port Policy:     static
    Protocol:        UDP
  Template:
    Metadata:
      Creation Timestamp:  <nil>
    Spec:
      Containers:
        Image:              index.docker.io/trota/pymuws
        Image Pull Policy:  Always
        Name:               pymuws-server
        Resources:
      Image Pull Secrets:
        Name:  regcred
Status:
  Address:    104.196.62.83
  Node Name:  gke-agones-pymuws-cluste-default-pool-a6421e45-93jd
  Ports:
    Name:  default
    Port:  7777
  State:   Allocated
Events:
  Type    Reason     Age   From                        Message
  ----    ------     ----  ----                        -------
  Normal  Creating   12m   gameserver-controller       Pod pymuws-clfzv-q7q5g-qfxlx created
  Normal  Starting   12m   gameserver-controller       Address and Port populated
  Normal  Ready      9m    gameserver-controller       SDK.Ready() executed
  Normal  Allocated  55s   fleetallocation-controller  Allocated from Fleet pymuws

Tom Rota

unread,
Sep 4, 2018, 12:13:12 PM9/4/18
to agones-discuss
Here is output from kubectl logs --namespace=agones-system agones-controller-66457c6f54-47gvc
after trying to allocate:

{"level":"info","msg":"Processing obj","obj":"default/pymuws-clfzv","queue":"stable.agones.dev.GameServerSetController","source":"*gameserversets.Controller","time":"2018-09-04T16:06:27Z"}
{"key":"default/pymuws-clfzv","level":"info","msg":"Synchronising","source":"*gameserversets.Controller","time":"2018-09-04T16:06:27Z"}
{"level":"info","msg":"running webhook","path":"/mutate","source":"*webhooks.WebHook","time":"2018-09-04T16:06:46Z"}
{"level":"info","msg":"creationMutationHandler","review":{"kind":"AdmissionReview","apiVersion":"admission.k8s.io/v1beta1","request":{"uid":"85daa026-b05c-11e8-a90d-42010a8e0099","kind":{"group":"stable.agones.dev","version":"v1alpha1","kind":"FleetAllocation"},"resource":{"group":"stable.agones.dev","version":"v1alpha1","resource":"fleetallocations"},"namespace":"default","operation":"CREATE","userInfo":{"username":"system:serviceaccount:default:fleet-allocator","uid":"85ce4abd-b059-11e8-b13c-42010a8e0007","groups":["system:serviceaccounts","system:serviceaccounts:default","system:authenticated"]},"object":{"apiVersion":"stable.agones.dev/v1alpha1","kind":"FleetAllocation","metadata":{"creationTimestamp":null,"generateName":"pymuws-","namespace":"default"},"spec":{"fleetName":"pymuws","metadata":{}},"status":{"GameServer":null}},"oldObject":null},"response":{"uid":"","allowed":true}},"source":"*fleetallocation.Controller","time":"2018-09-04T16:06:46Z"}
{"key":"default/pymuws-clfzv","level":"info","msg":"Enqueuing key","queue":"stable.agones.dev.GameServerSetController","source":"*gameserversets.Controller","time":"2018-09-04T16:06:46Z"}
{"key":"default/pymuws-clfzv-kqsgg","level":"info","msg":"Enqueuing key","queue":"stable.agones.dev.GameServerController","source":"*gameservers.Controller","time":"2018-09-04T16:06:46Z"}
{"fa":"","level":"info","msg":"patch created!","patch":"[{\"op\":\"add\",\"path\":\"/metadata/ownerReferences\",\"value\":[{\"apiVersion\":\"stable.agones.dev/v1alpha1\",\"blockOwnerDeletion\":true,\"controller\":true,\"kind\":\"GameServer\",\"name\":\"pymuws-clfzv-kqsgg\",\"uid\":\"40d3e195-b059-11e8-95e0-42010a8e00c1\"}]},{\"op\":\"replace\",\"path\":\"/status/GameServer\",\"value\":{\"metadata\":{\"creationTimestamp\":\"2018-09-04T15:43:22Z\",\"finalizers\":[\"stable.agones.dev\"],\"generateName\":\"pymuws-clfzv-\",\"generation\":1,\"labels\":{\"stable.agones.dev/gameserverset\":\"pymuws-clfzv\"},\"name\":\"pymuws-clfzv-kqsgg\",\"namespace\":\"default\",\"ownerReferences\":[{\"apiVersion\":\"stable.agones.dev/v1alpha1\",\"blockOwnerDeletion\":true,\"controller\":true,\"kind\":\"GameServerSet\",\"name\":\"pymuws-clfzv\",\"uid\":\"40c9d095-b059-11e8-95e0-42010a8e00c1\"}],\"resourceVersion\":\"4953\",\"selfLink\":\"/apis/stable.agones.dev/v1alpha1/namespaces/default/gameservers/pymuws-clfzv-kqsgg\",\"uid\":\"40d3e195-b059-11e8-95e0-42010a8e00c1\"},\"spec\":{\"container\":\"pymuws-server\",\"health\":{\"failureThreshold\":3,\"initialDelaySeconds\":60,\"periodSeconds\":5},\"ports\":[{\"containerPort\":26000,\"hostPort\":7777,\"name\":\"default\",\"portPolicy\":\"static\",\"protocol\":\"UDP\"}],\"template\":{\"metadata\":{\"creationTimestamp\":null},\"spec\":{\"containers\":[{\"image\":\"index.docker.io/trota/pymuws\",\"imagePullPolicy\":\"Always\",\"name\":\"pymuws-server\",\"resources\":{}}],\"imagePullSecrets\":[{\"name\":\"regcred\"}]}}},\"status\":{\"address\":\"35.227.72.81\",\"nodeName\":\"gke-agones-pymuws-cluste-default-pool-a6421e45-974t\",\"ports\":[{\"name\":\"default\",\"port\":7777}],\"state\":\"Allocated\"}}}]","source":"*fleetallocation.Controller","time":"2018-09-04T16:06:46Z"}
{"level":"info","msg":"Event(v1.ObjectReference{Kind:\"GameServer\", Namespace:\"default\", Name:\"pymuws-clfzv-kqsgg\", UID:\"40d3e195-b059-11e8-95e0-42010a8e00c1\", APIVersion:\"stable.agones.dev\", ResourceVersion:\"4953\", FieldPath:\"\"}): type: 'Normal' reason: 'Allocated' Allocated from Fleet pymuws","source":"*fleetallocation.Controller","time":"2018-09-04T16:06:46Z"}
{"level":"info","msg":"Processing obj","obj":"default/pymuws-clfzv","queue":"stable.agones.dev.GameServerSetController","source":"*gameserversets.Controller","time":"2018-09-04T16:06:46Z"}
{"key":"default/pymuws-clfzv","level":"info","msg":"Synchronising","source":"*gameserversets.Controller","time":"2018-09-04T16:06:46Z"}
{"level":"info","msg":"Processing obj","obj":"default/pymuws-clfzv-kqsgg","queue":"stable.agones.dev.GameServerController","source":"*gameservers.Controller","time":"2018-09-04T16:06:46Z"}
{"key":"default/pymuws-clfzv-kqsgg","level":"info","msg":"Synchronising","source":"*gameservers.Controller","time":"2018-09-04T16:06:46Z"}
{"level":"info","msg":"running webhook","path":"/validate","source":"*webhooks.WebHook","time":"2018-09-04T16:06:46Z"}
{"level":"info","msg":"updateValidationHandler","review":{"kind":"AdmissionReview","apiVersion":"admission.k8s.io/v1beta1","request":{"uid":"85edbcc4-b05c-11e8-95e0-42010a8e00c1","kind":{"group":"stable.agones.dev","version":"v1alpha1","kind":"GameServerSet"},"resource":{"group":"stable.agones.dev","version":"v1alpha1","resource":"gameserversets"},"name":"pymuws-clfzv","namespace":"default","operation":"UPDATE","userInfo":{"username":"system:serviceaccount:agones-system:agones-controller","uid":"2feb64d5-b059-11e8-b13c-42010a8e0007","groups":["system:serviceaccounts","system:serviceaccounts:agones-system","system:authenticated"]},"object":{"apiVersion":"stable.agones.dev/v1alpha1","kind":"GameServerSet","metadata":{"clusterName":"","creationTimestamp":"2018-09-04T15:43:22Z","generateName":"pymuws-","generation":1,"labels":{"stable.agones.dev/fleet":"pymuws"},"name":"pymuws-clfzv","namespace":"default","ownerReferences":[{"apiVersion":"stable.agones.dev/v1alpha1","blockOwnerDeletion":true,"controller":true,"kind":"Fleet","name":"pymuws","uid":"40c63db4-b059-11e8-a90d-42010a8e0099"}],"resourceVersion":"2913","selfLink":"/apis/stable.agones.dev/v1alpha1/namespaces/default/gameserversets/pymuws-clfzv","uid":"40c9d095-b059-11e8-95e0-42010a8e00c1"},"spec":{"replicas":2,"template":{"metadata":{"creationTimestamp":null},"spec":{"health":{"failureThreshold":3,"initialDelaySeconds":60,"periodSeconds":5},"ports":[{"containerPort":26000,"hostPort":7777,"name":"default","portPolicy":"static","protocol":"UDP"}],"template":{"metadata":{"creationTimestamp":null},"spec":{"containers":[{"image":"index.docker.io/trota/pymuws","imagePullPolicy":"Always","name":"pymuws-server","resources":{}}],"imagePullSecrets":[{"name":"regcred"}]}}}}},"status":{"allocatedReplicas":2,"readyReplicas":0,"replicas":2}},"oldObject":{"apiVersion":"stable.agones.dev/v1alpha1","kind":"GameServerSet","metadata":{"clusterName":"","creationTimestamp":"2018-09-04T15:43:22Z","generateName":"pymuws-","generation":1,"labels":{"stable.agones.dev/fleet":"pymuws"},"name":"pymuws-clfzv","namespace":"default","ownerReferences":[{"apiVersion":"stable.agones.dev/v1alpha1","blockOwnerDeletion":true,"controller":true,"kind":"Fleet","name":"pymuws","uid":"40c63db4-b059-11e8-a90d-42010a8e0099"}],"resourceVersion":"2913","selfLink":"","uid":"40c9d095-b059-11e8-95e0-42010a8e00c1"},"spec":{"replicas":2,"template":{"metadata":{"creationTimestamp":null},"spec":{"health":{"failureThreshold":3,"initialDelaySeconds":60,"periodSeconds":5},"ports":[{"containerPort":26000,"hostPort":7777,"name":"default","portPolicy":"static","protocol":"UDP"}],"template":{"metadata":{"creationTimestamp":null},"spec":{"containers":[{"image":"index.docker.io/trota/pymuws","imagePullPolicy":"Always","name":"pymuws-server","resources":{}}],"imagePullSecrets":[{"name":"regcred"}]}}}}},"status":{"allocatedReplicas":1,"readyReplicas":1,"replicas":2}}},"response":{"uid":"","allowed":true}},"source":"*gameserversets.Controller","time":"2018-09-04T16:06:46Z"}



On Tuesday, September 4, 2018 at 11:34:19 AM UTC-4, Mark Mandel wrote:

Mark Mandel

unread,
Sep 4, 2018, 3:51:13 PM9/4/18
to Tom Rota, agones-discuss
Hmn, so no errors.

But the gameserver you showed, you did successfully allocate it? Or did some other thing happen, not entirely sure I follow? How did it get to an allocated state?

As a potentially silly question - is the fleet you are trying to allocate from, does it exist? :)

Mark

Tom Rota

unread,
Sep 4, 2018, 4:30:29 PM9/4/18
to agones-discuss
Yeah, that is the weird part...how did it get to an allocated state?

The error from the pod running the service is error: "Internal error occurred: Internal error occurred: jsonpatch replace operation does not apply: doc is missing key: /status/GameServer" sounds like it comes from a package that gets imported by Agones.  At least, I couldn't find any error strings like that in the repo.

Yes, the fleet exists.  I check for that and log it.  I was wondering the same thing, as it seems like it gets lost.  If it knows the fleet, it should know the gameserver spec, right?

Here is the service I'm writing if you wouldn't mind looking.

Maybe I am going about this the wrong way?

Mark Mandel

unread,
Sep 4, 2018, 4:50:53 PM9/4/18
to Tom Rota, agones-discuss
Hmnn. I am confused as well. It seems like it should be fine. Sounds like K8s doesn't like the JSONPatch generated here:

Sounds like we also need an e2e test for this.

What K8s version/platform are you on?

Mark

Tom Rota

unread,
Sep 5, 2018, 9:54:07 AM9/5/18
to agones-discuss
My kubectl version...
Client Version: version.Info{Major:"1", Minor:"9", GitVersion:"v1.9.7", GitCommit:"dd5e1a2978fd0b97d9b78e1564398aeea7e7fe92", GitTreeState:"clean", BuildDate:"2018-04-19T00:05:56Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"10+", GitVersion:"v1.10.6-gke.2", GitCommit:"384b4eaa132ca9a295fcb3e5dfc74062b257e7df", GitTreeState:"clean", BuildDate:"2018-08-15T00:10:14Z", GoVersion:"go1.9.3b4", Compiler:"gc", Platform:"linux/amd64"}

I'll check the values being passed to jsonpatch.CreatePatch.

Mark Mandel

unread,
Sep 5, 2018, 11:13:45 AM9/5/18
to Tom Rota, agones-discuss
I'm going to also jump on writing an e2e test for this, see what i can find as well.

Tom Rota

unread,
Sep 5, 2018, 11:57:11 AM9/5/18
to agones-discuss
That would be great.  I see you guys have some issues logged for more e2e tests.

I found some errors in my agones-system agones-controller logs.  These occur after bringing up the fleet and prior to calling Create(fa).  Maybe something is just misconfigred?

First this...

{"error":"error getting external address for GameServer pymuws-jfcqh-9tdtv: error retrieving node  for Pod pymuws-jfcqh-9tdtv-hfvhp: node \"\" not found","level":"error","msg":"","obj":"default/pymuws-jfcqh-9tdtv","queue":"stable.agones.dev.GameServerController","source":"*gameservers.Controller","time":"2018-09-05T14:59:42Z"}
{"level":"error","msg":"error getting external address for GameServer pymuws-jfcqh-9tdtv: error retrieving node  for Pod pymuws-jfcqh-9tdtv-hfvhp: node \"\" not found","stack":["agones.dev/agones/pkg/gameservers.(*Controller).applyGameServerAddressAndPort\n\t/go/src/agones.dev/agones/pkg/gameservers/controller.go:505","agones.dev/agones/pkg/gameservers.(*Controller).syncGameServerCreatingState\n\t/go/src/agones.dev/agones/pkg/gameservers/controller.go:393","agones.dev/agones/pkg/gameservers.(*Controller).syncGameServer\n\t/go/src/agones.dev/agones/pkg/gameservers/controller.go:282","agones.dev/agones/pkg/gameservers.(*Controller).(agones.dev/agones/pkg/gameservers.syncGameServer)-fm\n\t/go/src/agones.dev/agones/pkg/gameservers/controller.go:115","agones.dev/agones/pkg/util/workerqueue.(*WorkerQueue).processNextWorkItem\n\t/go/src/agones.dev/agones/pkg/util/workerqueue/workerqueue.go:107","agones.dev/agones/pkg/util/workerqueue.(*WorkerQueue).runWorker\n\t/go/src/agones.dev/agones/pkg/util/workerqueue/workerqueue.go:83","agones.dev/agones/pkg/util/workerqueue.(*WorkerQueue).(agones.dev/agones/pkg/util/workerqueue.runWorker)-fm\n\t/go/src/agones.dev/agones/pkg/util/workerqueue/workerqueue.go:135","agones.dev/agones/vendor/k8s.io/apimachinery/pkg/util/wait.JitterUntil.func1\n\t/go/src/agones.dev/agones/vendor/k8s.io/apimachinery/pkg/util/wait/wait.go:133","agones.dev/agones/vendor/k8s.io/apimachinery/pkg/util/wait.JitterUntil\n\t/go/src/agones.dev/agones/vendor/k8s.io/apimachinery/pkg/util/wait/wait.go:134","agones.dev/agones/vendor/k8s.io/apimachinery/pkg/util/wait.Until\n\t/go/src/agones.dev/agones/vendor/k8s.io/apimachinery/pkg/util/wait/wait.go:88","agones.dev/agones/pkg/util/workerqueue.(*WorkerQueue).run\n\t/go/src/agones.dev/agones/pkg/util/workerqueue/workerqueue.go:135","runtime.goexit\n\t/usr/local/go/src/runtime/asm_amd64.s:2361"],"time":"2018-09-05T14:59:42Z"}


A little later on, maybe when the gs calls /ready, it seems to forget the controller service account...

ERROR: logging before flag.Parse: E0905 15:02:13.198532       1 event.go:200] Server rejected event '&v1.Event{TypeMeta:v1.TypeMeta{Kind:"", APIVersion:""}, ObjectMeta:v1.ObjectMeta{Name:"pymuws-jfcqh-9tdtv.155189236c4e7322", GenerateName:"", Namespace:"default", SelfLink:"", UID:"", ResourceVersion:"440", Generation:0, CreationTimestamp:v1.Time{Time:time.Time{wall:0x0, ext:0, loc:(*time.Location)(nil)}}, DeletionTimestamp:(*v1.Time)(nil), DeletionGracePeriodSeconds:(*int64)(nil), Labels:map[string]string(nil), Annotations:map[string]string(nil), OwnerReferences:[]v1.OwnerReference(nil), Initializers:(*v1.Initializers)(nil), Finalizers:[]string(nil), ClusterName:""}, InvolvedObject:v1.ObjectReference{Kind:"GameServer", Namespace:"default", Name:"pymuws-jfcqh-9tdtv", UID:"518f9f95-b11c-11e8-92af-42010a8e00e5", APIVersion:"stable.agones.dev", ResourceVersion:"1374", FieldPath:""}, Reason:"Ready", Message:"SDK.Ready() executed", Source:v1.EventSource{Component:"gameserver-controller", Host:""}, FirstTimestamp:v1.Time{Time:time.Time{wall:0x0, ext:63671756533, loc:(*time.Location)(0x1bc3a60)}}, LastTimestamp:v1.Time{Time:time.Time{wall:0xbedc19dd4a68fb41, ext:158982060102, loc:(*time.Location)(0x1bc3a60)}}, Count:2, Type:"Normal", EventTime:v1.MicroTime{Time:time.Time{wall:0x0, ext:0, loc:(*time.Location)(nil)}}, Series:(*v1.EventSeries)(nil), Action:"", Related:(*v1.ObjectReference)(nil), ReportingController:"", ReportingInstance:""}': 'events "pymuws-jfcqh-9tdtv.155189236c4e7322" is forbidden: User "system:serviceaccount:agones-system:agones-controller" cannot patch events in the namespace "default": Unknown user "system:serviceaccount:agones-system:agones-controller"' (will not retry!)

Mark Mandel

unread,
Sep 6, 2018, 11:38:57 PM9/6/18
to Tom Rota, agones-discuss
You'll be pleased to know, I created an e2e test:

And got exactly the same error.

So I don't think you are doing anything wrong -- this is a very strange one. Digging in!

Mark

Mark Mandel

unread,
Sep 7, 2018, 1:29:33 AM9/7/18
to Tom Rota, agones-discuss
Hi!

So I have a fix here (and the PR shows what the issue is)

I'd love some user testing - can you see if the client from this PR will solve your problem, or if you have to do a full deploy with the build from this PR to solve it?

It may also be possible to create a workaround, by setting the values for the Gameserver status and other nullable pointers.

Considering doing a hotfix to solve this issue.

Thanks for finding this bug! There is now an e2e test to make sure it never happens again!

Mark

Tom Rota

unread,
Sep 7, 2018, 10:33:33 AM9/7/18
to agones-discuss
Thanks Mark!  The fix you describe in the PR makes sense.

I'm installing it now on gke with agones.image.tag=0.5.0-03f4866 and will let you know how it goes.

Tom Rota

unread,
Sep 7, 2018, 11:04:19 AM9/7/18
to agones-discuss
Your fix works great!  Now
fleetAllocationInterface := agonesClient.StableV1alpha1().FleetAllocations(namespace)
newFleetAllocation, err := fleetAllocationInterface.Create(fa)
creates one allocation, and no errors.

Good to know the end to end test is keeping an eye on the future.

A hotfix might not be neccessary.  This test was successful after downloading the agones-install-0.4.0.zip and then
helm install --name pymuws-server --namespace agones-system agones --set agones.image.tag=0.5.0-03f4866

Also, thank you for the workaround idea.

Mark Mandel

unread,
Sep 7, 2018, 11:20:51 AM9/7/18
to Tom Rota, agones-discuss
Excellent - glad to hear it's working for you!

MArk

Reply all
Reply to author
Forward
0 new messages