Skip to content

Commit

Permalink
Add status subresource to fleet and Gameserverset
Browse files Browse the repository at this point in the history
Switch to using UpdateStatus function when it is necessary, add RBAC
permissions for "fleets/status" and "gameserversets/status".
  • Loading branch information
aLekSer committed Feb 14, 2019
1 parent 4b8c120 commit 3a5fca4
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 6 deletions.
2 changes: 2 additions & 0 deletions install/helm/agones/templates/crds/fleet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions install/helm/agones/templates/crds/gameserverset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions install/helm/agones/templates/serviceaccounts/controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
8 changes: 6 additions & 2 deletions install/yaml/install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion pkg/fleets/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/gameserversets/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 3a5fca4

Please sign in to comment.