diff --git a/controllers/dscinitialization/servicemesh_setup.go b/controllers/dscinitialization/servicemesh_setup.go index cd5aa4ba93e..7bd2dd0dc07 100644 --- a/controllers/dscinitialization/servicemesh_setup.go +++ b/controllers/dscinitialization/servicemesh_setup.go @@ -90,18 +90,6 @@ func configureServiceMeshFeatures(s *feature.FeaturesInitializer) error { } s.Features = append(s.Features, smcpCreation) - noDefaultNetworkPolicies, errNp := feature.CreateFeature("mesh-control-plane-no-default-network-policies"). - For(s.DSCInitializationSpec). - Manifests( - path.Join(rootDir, templatesDir, "base", "control-plane-disable-networkpolicies.patch.tmpl"), - ). - Load() - - if errNp != nil { - return errNp - } - s.Features = append(s.Features, noDefaultNetworkPolicies) - if serviceMeshSpec.ControlPlane.MetricsCollection == "Istio" { metricsCollection, errMetrics := feature.CreateFeature("mesh-metrics-collection"). For(s.DSCInitializationSpec). diff --git a/pkg/feature/templates/servicemesh/base/control-plane-disable-networkpolicies.patch.tmpl b/pkg/feature/templates/servicemesh/base/control-plane-disable-networkpolicies.patch.tmpl deleted file mode 100644 index 09a54e96ae4..00000000000 --- a/pkg/feature/templates/servicemesh/base/control-plane-disable-networkpolicies.patch.tmpl +++ /dev/null @@ -1,8 +0,0 @@ -apiVersion: maistra.io/v2 -kind: ServiceMeshControlPlane -metadata: - name: {{ .ControlPlane.Name }} - namespace: {{ .ControlPlane.Namespace }} -spec: - security: - manageNetworkPolicy: false diff --git a/tests/integration/features/servicemesh_feature_test.go b/tests/integration/features/servicemesh_feature_test.go index b28073bee76..5b955322af8 100644 --- a/tests/integration/features/servicemesh_feature_test.go +++ b/tests/integration/features/servicemesh_feature_test.go @@ -2,10 +2,6 @@ package features_test import ( "context" - "io" - "os" - "path" - "path/filepath" apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -16,7 +12,6 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/envtest" - dscv1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/dscinitialization/v1" "github.com/opendatahub-io/opendatahub-operator/v2/pkg/feature" "github.com/opendatahub-io/opendatahub-operator/v2/pkg/feature/servicemesh" "github.com/opendatahub-io/opendatahub-operator/v2/pkg/gvr" @@ -100,60 +95,6 @@ var _ = Describe("Service Mesh feature", func() { }) }) }) - - Describe("control plane configuration", func() { - - var ( - dsciSpec *dscv1.DSCInitializationSpec - smcpCRD *apiextensionsv1.CustomResourceDefinition - name = "data-science-smcp" - appNamespace = "opendatahub" - ) - - BeforeEach(func() { - dsciSpec = newDSCInitializationSpec(appNamespace) - smcpCRD = installServiceMeshControlPlaneCRD() - }) - - AfterEach(func() { - defer objectCleaner.DeleteAll(smcpCRD) - }) - - It("should disable automated network policy by patching existing SMCP", func() { - // given - namespace := envtestutil.AppendRandomNameTo(testNamespacePrefix) - ns := createNamespace(namespace) - Expect(envTestClient.Create(context.Background(), ns)).To(Succeed()) - defer objectCleaner.DeleteAll(ns) - - createServiceMeshControlPlane(name, namespace) - - dsciSpec.ServiceMesh.ControlPlane.Name = name - dsciSpec.ServiceMesh.ControlPlane.Namespace = namespace - - controlPlaneWithNetworkPoliciesMgmtDisabled, err := feature.CreateFeature("control-plane-with-disabled-network-policies"). - For(dsciSpec). - Manifests(fromTestTmpDir(path.Join("templates/servicemesh/base", "control-plane-disable-networkpolicies.patch.tmpl"))). - UsingConfig(envTest.Config). - Load() - - Expect(err).ToNot(HaveOccurred()) - - // when - Expect(controlPlaneWithNetworkPoliciesMgmtDisabled.Apply()).To(Succeed()) - - // then - serviceMeshControlPlane, err := getServiceMeshControlPlane(envTest.Config, namespace, name) - Expect(err).ToNot(HaveOccurred()) - - networkPolicyManagement, found, err := unstructured.NestedBool(serviceMeshControlPlane.Object, "spec", "security", "manageNetworkPolicy") - Expect(err).ToNot(HaveOccurred()) - Expect(found).To(BeTrue()) - Expect(networkPolicyManagement).To(BeFalse()) - }) - - }) - }) func installServiceMeshControlPlaneCRD() *apiextensionsv1.CustomResourceDefinition { @@ -273,56 +214,3 @@ func createSMCPInCluster(cfg *rest.Config, smcpObj *unstructured.Unstructured, n return nil } - -func getServiceMeshControlPlane(cfg *rest.Config, namespace, name string) (*unstructured.Unstructured, error) { - dynamicClient, err := dynamic.NewForConfig(cfg) - if err != nil { - return nil, err - } - - smcp, err := dynamicClient.Resource(gvr.SMCP).Namespace(namespace).Get(context.TODO(), name, metav1.GetOptions{}) - if err != nil { - return nil, err - } - - return smcp, nil -} - -func fromTestTmpDir(fileName string) string { - root, err := envtestutil.FindProjectRoot() - Expect(err).ToNot(HaveOccurred()) - - tmpDir := filepath.Join(os.TempDir(), envtestutil.RandomUUIDName(16)) - if err := os.Mkdir(tmpDir, os.ModePerm); err != nil { - Fail(err.Error()) - } - - src := path.Join(root, "pkg", "feature", fileName) - dest := path.Join(tmpDir, fileName) - if err := copyFile(src, dest); err != nil { - Fail(err.Error()) - } - - return dest -} - -func copyFile(src, dst string) error { - source, err := os.Open(src) - if err != nil { - return err - } - defer source.Close() - - if err := os.MkdirAll(filepath.Dir(dst), os.ModePerm); err != nil { - return err - } - - destination, err := os.Create(dst) - if err != nil { - return err - } - defer destination.Close() - - _, err = io.Copy(destination, source) - return err -}