diff --git a/internal/provider/kubernetes/controller.go b/internal/provider/kubernetes/controller.go index 92e54d692c2d..ab65bdc79b8a 100644 --- a/internal/provider/kubernetes/controller.go +++ b/internal/provider/kubernetes/controller.go @@ -1031,9 +1031,9 @@ func (r *gatewayAPIReconciler) removeFinalizer(ctx context.Context, obj client.O } return nil case *egv1a1.EnvoyProxy: - if slice.ContainsString(objType.Finalizers, gatewayClassFinalizer) { + if slice.ContainsString(objType.Finalizers, envoyProxyFinalizer) { base := client.MergeFrom(objType.DeepCopy()) - objType.Finalizers = slice.RemoveString(objType.Finalizers, gatewayClassFinalizer) + objType.Finalizers = slice.RemoveString(objType.Finalizers, envoyProxyFinalizer) if err := r.client.Patch(ctx, objType, base); err != nil { return fmt.Errorf("failed to add finalizer to Envoy Proxy %s: %w", objType.Name, err) } @@ -1057,9 +1057,9 @@ func (r *gatewayAPIReconciler) addFinalizer(ctx context.Context, obj client.Obje } return nil case *egv1a1.EnvoyProxy: - if !slice.ContainsString(objType.Finalizers, gatewayClassFinalizer) { + if !slice.ContainsString(objType.Finalizers, envoyProxyFinalizer) { base := client.MergeFrom(objType.DeepCopy()) - objType.Finalizers = append(objType.Finalizers, gatewayClassFinalizer) + objType.Finalizers = append(objType.Finalizers, envoyProxyFinalizer) if err := r.client.Patch(ctx, objType, base); err != nil { return fmt.Errorf("failed to add finalizer to Envoy Proxy %s: %w", objType.Name, err) } diff --git a/internal/provider/kubernetes/controller_test.go b/internal/provider/kubernetes/controller_test.go index 19e2830cadda..a45d37f5573f 100644 --- a/internal/provider/kubernetes/controller_test.go +++ b/internal/provider/kubernetes/controller_test.go @@ -99,7 +99,7 @@ func TestAddEnvoyProxyFinalizer(t *testing.T) { Name: "test", }, }, - expect: []string{gatewayClassFinalizer}, + expect: []string{envoyProxyFinalizer}, }, { name: "envoyproxy with a different finalizer", @@ -109,17 +109,17 @@ func TestAddEnvoyProxyFinalizer(t *testing.T) { Finalizers: []string{"fooFinalizer"}, }, }, - expect: []string{"fooFinalizer", gatewayClassFinalizer}, + expect: []string{"fooFinalizer", envoyProxyFinalizer}, }, { name: "envoyproxy with existing gatewayclass finalizer", ep: &egv1a1.EnvoyProxy{ ObjectMeta: metav1.ObjectMeta{ Name: "test-ep", - Finalizers: []string{gatewayClassFinalizer}, + Finalizers: []string{envoyProxyFinalizer}, }, }, - expect: []string{gatewayClassFinalizer}, + expect: []string{envoyProxyFinalizer}, }, } // Create the reconciler. @@ -170,7 +170,7 @@ func TestRemoveEnvoyProxyFinalizer(t *testing.T) { ep: &egv1a1.EnvoyProxy{ ObjectMeta: metav1.ObjectMeta{ Name: "test-ep", - Finalizers: []string{gatewayClassFinalizer}, + Finalizers: []string{envoyProxyFinalizer}, }, }, expect: nil, diff --git a/internal/provider/kubernetes/helpers.go b/internal/provider/kubernetes/helpers.go index 847bdc352613..a5ac5883a3f4 100644 --- a/internal/provider/kubernetes/helpers.go +++ b/internal/provider/kubernetes/helpers.go @@ -22,6 +22,7 @@ import ( const ( gatewayClassFinalizer = gwapiv1.GatewayClassFinalizerGatewaysExist + envoyProxyFinalizer = "gatewayclass-exists-finalizer.gateway.envoyproxy.github.com" ) type ObjectKindNamespacedName struct { diff --git a/internal/provider/kubernetes/kubernetes_test.go b/internal/provider/kubernetes/kubernetes_test.go index b91244f4c459..2d43f9806d06 100644 --- a/internal/provider/kubernetes/kubernetes_test.go +++ b/internal/provider/kubernetes/kubernetes_test.go @@ -219,7 +219,7 @@ func testGatewayClassWithParamRef(ctx context.Context, t *testing.T, provider *P // Ensure the envoyproxy has not been finalized. require.Eventually(t, func() bool { err := cli.Get(ctx, types.NamespacedName{Name: ep.Name, Namespace: testNs}, ep) - return err == nil && !slices.Contains(ep.Finalizers, gatewayClassFinalizer) + return err == nil && !slices.Contains(ep.Finalizers, envoyProxyFinalizer) }, defaultWait, defaultTick) // Ensure the gateway class has not been finalized. @@ -343,7 +343,7 @@ func testGatewayClassWithParamRef(ctx context.Context, t *testing.T, provider *P // Ensure the envoyproxy has been finalized. require.Eventually(t, func() bool { err := cli.Get(ctx, types.NamespacedName{Name: ep.Name, Namespace: testNs}, ep) - return err == nil && slices.Contains(ep.Finalizers, gatewayClassFinalizer) + return err == nil && slices.Contains(ep.Finalizers, envoyProxyFinalizer) }, defaultWait, defaultTick) //Ensure that envoyproxy finalizer will be removed when GatewayClass stops referencing it @@ -351,7 +351,7 @@ func testGatewayClassWithParamRef(ctx context.Context, t *testing.T, provider *P require.NoError(t, cli.Update(ctx, gc)) require.Eventually(t, func() bool { err := cli.Get(ctx, types.NamespacedName{Name: ep.Name, Namespace: testNs}, ep) - return err == nil && !slices.Contains(ep.Finalizers, gatewayClassFinalizer) + return err == nil && !slices.Contains(ep.Finalizers, envoyProxyFinalizer) }, defaultWait, defaultTick) }