From 3a5fca47fa5e9b536dd8851aed6476c84699080f Mon Sep 17 00:00:00 2001 From: Alexander Apalikov Date: Fri, 8 Feb 2019 12:34:48 +0300 Subject: [PATCH] Add status subresource to fleet and Gameserverset Switch to using UpdateStatus function when it is necessary, add RBAC permissions for "fleets/status" and "gameserversets/status". --- install/helm/agones/templates/crds/fleet.yaml | 2 ++ install/helm/agones/templates/crds/gameserverset.yaml | 2 ++ .../helm/agones/templates/serviceaccounts/controller.yaml | 4 ++-- install/yaml/install.yaml | 8 ++++++-- pkg/fleets/controller.go | 2 +- pkg/gameserversets/controller.go | 2 +- 6 files changed, 14 insertions(+), 6 deletions(-) diff --git a/install/helm/agones/templates/crds/fleet.yaml b/install/helm/agones/templates/crds/fleet.yaml index 25f3ad7745..fdece90e03 100644 --- a/install/helm/agones/templates/crds/fleet.yaml +++ b/install/helm/agones/templates/crds/fleet.yaml @@ -79,6 +79,8 @@ spec: template: {{- include "gameserver.validation" . | indent 14 }} subresources: + # status enables the status subresource. + status: {} # scale enables the scale subresource. scale: # specReplicasPath defines the JSONPath inside of a custom resource that corresponds to Scale.Spec.Replicas. diff --git a/install/helm/agones/templates/crds/gameserverset.yaml b/install/helm/agones/templates/crds/gameserverset.yaml index 51baffb453..bac2efa30b 100644 --- a/install/helm/agones/templates/crds/gameserverset.yaml +++ b/install/helm/agones/templates/crds/gameserverset.yaml @@ -73,6 +73,8 @@ spec: template: {{- include "gameserver.validation" . | indent 14 }} subresources: + # status enables the status subresource. + status: {} # scale enables the scale subresource. scale: # specReplicasPath defines the JSONPath inside of a custom resource that corresponds to Scale.Spec.Replicas. diff --git a/install/helm/agones/templates/serviceaccounts/controller.yaml b/install/helm/agones/templates/serviceaccounts/controller.yaml index 3fd8ed3cb0..6d028fa82a 100644 --- a/install/helm/agones/templates/serviceaccounts/controller.yaml +++ b/install/helm/agones/templates/serviceaccounts/controller.yaml @@ -50,13 +50,13 @@ rules: resources: ["customresourcedefinitions"] verbs: ["get"] - apiGroups: ["stable.agones.dev"] - resources: ["gameservers", "gameserversets"] + resources: ["gameservers", "gameserversets", "gameserversets/status"] verbs: ["create", "delete", "get", "list", "update", "watch"] - apiGroups: ["stable.agones.dev"] resources: ["gameservers"] verbs: ["patch"] - apiGroups: ["stable.agones.dev"] - resources: ["fleets", "fleetallocations", "fleetautoscalers"] + resources: ["fleets", "fleets/status", "fleetallocations", "fleetautoscalers"] verbs: ["get", "list", "update", "watch"] - apiGroups: ["stable.agones.dev"] resources: ["gameserverallocations"] diff --git a/install/yaml/install.yaml b/install/yaml/install.yaml index 42673dc826..ab200db353 100644 --- a/install/yaml/install.yaml +++ b/install/yaml/install.yaml @@ -48,13 +48,13 @@ rules: resources: ["customresourcedefinitions"] verbs: ["get"] - apiGroups: ["stable.agones.dev"] - resources: ["gameservers", "gameserversets"] + resources: ["gameservers", "gameserversets", "gameserversets/status"] verbs: ["create", "delete", "get", "list", "update", "watch"] - apiGroups: ["stable.agones.dev"] resources: ["gameservers"] verbs: ["patch"] - apiGroups: ["stable.agones.dev"] - resources: ["fleets", "fleetallocations", "fleetautoscalers"] + resources: ["fleets", "fleets/status", "fleetallocations", "fleetautoscalers"] verbs: ["get", "list", "update", "watch"] - apiGroups: ["stable.agones.dev"] resources: ["gameserverallocations"] @@ -328,6 +328,8 @@ spec: minimum: 1 maximum: 2147483648 subresources: + # status enables the status subresource. + status: {} # scale enables the scale subresource. scale: # specReplicasPath defines the JSONPath inside of a custom resource that corresponds to Scale.Spec.Replicas. @@ -936,6 +938,8 @@ spec: minimum: 1 maximum: 2147483648 subresources: + # status enables the status subresource. + status: {} # scale enables the scale subresource. scale: # specReplicasPath defines the JSONPath inside of a custom resource that corresponds to Scale.Spec.Replicas. diff --git a/pkg/fleets/controller.go b/pkg/fleets/controller.go index a01aa15c4d..37217bd45a 100644 --- a/pkg/fleets/controller.go +++ b/pkg/fleets/controller.go @@ -450,7 +450,7 @@ func (c *Controller) updateFleetStatus(fleet *stablev1alpha1.Fleet) error { fCopy.Status.AllocatedReplicas += gsSet.Status.AllocatedReplicas } - _, err = c.fleetGetter.Fleets(fCopy.Namespace).Update(fCopy) + _, err = c.fleetGetter.Fleets(fCopy.Namespace).UpdateStatus(fCopy) return errors.Wrapf(err, "error updating status of fleet %s", fCopy.ObjectMeta.Name) } diff --git a/pkg/gameserversets/controller.go b/pkg/gameserversets/controller.go index 8f39c711ac..2303092e30 100644 --- a/pkg/gameserversets/controller.go +++ b/pkg/gameserversets/controller.go @@ -519,7 +519,7 @@ func (c *Controller) updateStatusIfChanged(gsSet *v1alpha1.GameServerSet, status if gsSet.Status != status { gsSetCopy := gsSet.DeepCopy() gsSetCopy.Status = status - _, err := c.gameServerSetGetter.GameServerSets(gsSet.ObjectMeta.Namespace).Update(gsSetCopy) + _, err := c.gameServerSetGetter.GameServerSets(gsSet.ObjectMeta.Namespace).UpdateStatus(gsSetCopy) if err != nil { return errors.Wrapf(err, "error updating status on GameServerSet %s", gsSet.ObjectMeta.Name) }