diff --git a/pkg/apis/agones/v1/gameserver.go b/pkg/apis/agones/v1/gameserver.go index 67eba0221d..2f5b10b99d 100644 --- a/pkg/apis/agones/v1/gameserver.go +++ b/pkg/apis/agones/v1/gameserver.go @@ -150,6 +150,8 @@ const ( // GameServerErroredAtAnnotation is an annotation that records the timestamp the GameServer entered the // error state. The timestamp is encoded in RFC3339 format. GameServerErroredAtAnnotation = agones.GroupName + "/errored-at" + // FinalizerName is the domain name and finalizer path used to manage garbage collection of the GameServer. + FinalizerName = agones.GroupName + "/controller" // NodePodIP identifies an IP address from a pod. NodePodIP corev1.NodeAddressType = "PodIP" @@ -362,7 +364,7 @@ func (gs *GameServer) ApplyDefaults() { gs.ObjectMeta.Annotations = map[string]string{} } gs.ObjectMeta.Annotations[VersionAnnotation] = pkg.Version - gs.ObjectMeta.Finalizers = append(gs.ObjectMeta.Finalizers, agones.GroupName) + gs.ObjectMeta.Finalizers = append(gs.ObjectMeta.Finalizers, FinalizerName) gs.Spec.ApplyDefaults() gs.applyStatusDefaults() diff --git a/pkg/apis/agones/v1/gameserver_test.go b/pkg/apis/agones/v1/gameserver_test.go index 91b2ded205..6563240b72 100644 --- a/pkg/apis/agones/v1/gameserver_test.go +++ b/pkg/apis/agones/v1/gameserver_test.go @@ -449,7 +449,7 @@ func TestGameServerApplyDefaults(t *testing.T) { assert.Equal(t, pkg.Version, test.gameServer.Annotations[VersionAnnotation]) spec := test.gameServer.Spec - assert.Contains(t, test.gameServer.ObjectMeta.Finalizers, agones.GroupName) + assert.Contains(t, test.gameServer.ObjectMeta.Finalizers, FinalizerName) assert.Equal(t, test.expected.container, spec.Container) assert.Equal(t, test.expected.protocol, spec.Ports[0].Protocol) assert.Equal(t, test.expected.portRange, spec.Ports[0].Range) diff --git a/pkg/gameservers/controller.go b/pkg/gameservers/controller.go index 6f20f5ea53..d44cce42a3 100644 --- a/pkg/gameservers/controller.go +++ b/pkg/gameservers/controller.go @@ -455,12 +455,12 @@ func (c *Controller) syncGameServerDeletionTimestamp(ctx context.Context, gs *ag // remove the finalizer for this controller var fin []string for _, f := range gsCopy.ObjectMeta.Finalizers { - if f != agones.GroupName { + if f != agones.GroupName && f != agonesv1.FinalizerName { fin = append(fin, f) } } gsCopy.ObjectMeta.Finalizers = fin - loggerForGameServer(gsCopy, c.baseLogger).Debugf("No pods found, removing finalizer %s", agones.GroupName) + loggerForGameServer(gsCopy, c.baseLogger).Debugf("No pods found, removing finalizer %s", agonesv1.FinalizerName) gs, err = c.gameServerGetter.GameServers(gsCopy.ObjectMeta.Namespace).Update(ctx, gsCopy, metav1.UpdateOptions{}) return gs, errors.Wrapf(err, "error removing finalizer for GameServer %s", gsCopy.ObjectMeta.Name) } diff --git a/pkg/gameservers/controller_test.go b/pkg/gameservers/controller_test.go index 7eb740776a..7d40f5ee9f 100644 --- a/pkg/gameservers/controller_test.go +++ b/pkg/gameservers/controller_test.go @@ -435,7 +435,7 @@ func TestControllerCreationMutationHandler(t *testing.T) { expected: expected{ responseAllowed: true, patches: []jsonpatch.JsonPatchOperation{ - {Operation: "add", Path: "/metadata/finalizers", Value: []interface{}{"agones.dev"}}, + {Operation: "add", Path: "/metadata/finalizers", Value: []interface{}{"agones.dev/controller"}}, {Operation: "add", Path: "/spec/ports/0/protocol", Value: "UDP"}}, }, },