diff --git a/pkg/istiovalues/overrides.go b/pkg/istiovalues/overrides.go index acb8333a5..1485d5085 100644 --- a/pkg/istiovalues/overrides.go +++ b/pkg/istiovalues/overrides.go @@ -14,7 +14,11 @@ package istiovalues -import v1 "github.com/istio-ecosystem/sail-operator/api/v1" +import ( + v1 "github.com/istio-ecosystem/sail-operator/api/v1" + + "istio.io/istio/pkg/ptr" +) func ApplyOverrides(revisionName string, namespace string, values *v1.Values) { // Set revision name to "" if revision name is "default". This is a temporary fix until we fix the injection @@ -30,4 +34,8 @@ func ApplyOverrides(revisionName string, namespace string, values *v1.Values) { values.Global = &v1.GlobalConfig{} } values.Global.IstioNamespace = &namespace + + // Force defaultRevision to be empty to prevent creation of the default validator webhook. + // This field is deprecated and should be ignored by the operator. + values.DefaultRevision = ptr.Of("") } diff --git a/pkg/istiovalues/overrides_test.go b/pkg/istiovalues/overrides_test.go index 5c75f8294..8506cb6b7 100644 --- a/pkg/istiovalues/overrides_test.go +++ b/pkg/istiovalues/overrides_test.go @@ -41,6 +41,7 @@ func TestApplyOverrides(t *testing.T) { Global: &v1.GlobalConfig{ IstioNamespace: ptr.Of("ns1"), }, + DefaultRevision: ptr.Of(""), }, }, { @@ -53,6 +54,7 @@ func TestApplyOverrides(t *testing.T) { Global: &v1.GlobalConfig{ IstioNamespace: ptr.Of("ns1"), }, + DefaultRevision: ptr.Of(""), }, }, { @@ -67,6 +69,7 @@ func TestApplyOverrides(t *testing.T) { Global: &v1.GlobalConfig{ IstioNamespace: ptr.Of("ns1"), }, + DefaultRevision: ptr.Of(""), }, }, { @@ -83,6 +86,22 @@ func TestApplyOverrides(t *testing.T) { Global: &v1.GlobalConfig{ IstioNamespace: ptr.Of("ns1"), }, + DefaultRevision: ptr.Of(""), + }, + }, + { + name: "defaultRevision-is-ignored-when-set-by-user", + revision: "my-revision", + namespace: "ns1", + values: v1.Values{ + DefaultRevision: ptr.Of("my-revision"), + }, + expectedValues: v1.Values{ + Revision: ptr.Of("my-revision"), + Global: &v1.GlobalConfig{ + IstioNamespace: ptr.Of("ns1"), + }, + DefaultRevision: ptr.Of(""), }, }, } diff --git a/pkg/revision/values_test.go b/pkg/revision/values_test.go index 0c6b175dd..f55d2edf4 100644 --- a/pkg/revision/values_test.go +++ b/pkg/revision/values_test.go @@ -83,7 +83,8 @@ spec: Platform: ptr.Of("openshift"), IstioNamespace: ptr.Of(namespace), // this value is always added/overridden based on IstioRevision.spec.namespace }, - Revision: ptr.Of(revisionName), + Revision: ptr.Of(revisionName), + DefaultRevision: ptr.Of(""), } if !reflect.DeepEqual(result, expected) { @@ -123,7 +124,8 @@ spec:`)), 0o644)) Platform: ptr.Of("openshift"), IstioNamespace: ptr.Of(namespace), // this value is always added/overridden based on IstioRevision.spec.namespace }, - Revision: ptr.Of(revisionName), + Revision: ptr.Of(revisionName), + DefaultRevision: ptr.Of(""), } if !reflect.DeepEqual(result, expected) { diff --git a/tests/integration/api/istiobase_test.go b/tests/integration/api/istiobase_test.go index f2f8b3fd2..4aa1e9dd2 100644 --- a/tests/integration/api/istiobase_test.go +++ b/tests/integration/api/istiobase_test.go @@ -56,6 +56,7 @@ var _ = Describe("base chart support", Ordered, func() { } saKey := client.ObjectKey{Name: "istio-reader-service-account", Namespace: istioNamespace} + validatingWebhookKey := client.ObjectKey{Name: "istiod-default-validator", Namespace: istioNamespace} BeforeAll(func() { Step(fmt.Sprintf("Creating namespace %q", istioNamespace)) @@ -99,6 +100,10 @@ var _ = Describe("base chart support", Ordered, func() { sa := &corev1.ServiceAccount{} Step("Checking if istio-reader ServiceAccount was successfully created") Eventually(k8sClient.Get).WithArguments(ctx, saKey, sa).Should(Succeed()) + + webhook := &admissionv1.ValidatingWebhookConfiguration{} + Step("Checking if default ValidatingWebhookConfiguration was successfully created") + Eventually(k8sClient.Get).WithArguments(ctx, validatingWebhookKey, webhook).Should(Succeed()) }) It("undeploys base chart when default IstioRevision is deleted", func() { @@ -108,6 +113,10 @@ var _ = Describe("base chart support", Ordered, func() { sa := &corev1.ServiceAccount{} Step("Checking if istio-reader ServiceAccount was deleted") Eventually(k8sClient.Get).WithArguments(ctx, saKey, sa).Should(ReturnNotFoundError()) + + webhook := &admissionv1.ValidatingWebhookConfiguration{} + Step("Checking if default ValidatingWebhookConfiguration was deleted") + Eventually(k8sClient.Get).WithArguments(ctx, validatingWebhookKey, webhook).Should(ReturnNotFoundError()) }) }) @@ -153,12 +162,20 @@ var _ = Describe("base chart support", Ordered, func() { sa := &corev1.ServiceAccount{} Step("Checking if istio-reader ServiceAccount was deleted") Eventually(k8sClient.Get).WithArguments(ctx, saKey, sa).Should(ReturnNotFoundError()) + + webhook := &admissionv1.ValidatingWebhookConfiguration{} + Step("Checking if default ValidatingWebhookConfiguration was deleted") + Eventually(k8sClient.Get).WithArguments(ctx, validatingWebhookKey, webhook).Should(ReturnNotFoundError()) }) It("deploys base chart when default IstioRevisionTag is created", func() { sa := &corev1.ServiceAccount{} Step("Checking if istio-reader ServiceAccount was successfully created") Eventually(k8sClient.Get).WithArguments(ctx, saKey, sa).Should(Succeed()) + + webhook := &admissionv1.ValidatingWebhookConfiguration{} + Step("Checking if default ValidatingWebhookConfiguration was successfully created") + Eventually(k8sClient.Get).WithArguments(ctx, validatingWebhookKey, webhook).Should(Succeed()) }) })