diff --git a/apis/clusters/v1beta1/kafka_webhook_test.go b/apis/clusters/v1beta1/kafka_webhook_test.go index 191eb2840..7653439cc 100644 --- a/apis/clusters/v1beta1/kafka_webhook_test.go +++ b/apis/clusters/v1beta1/kafka_webhook_test.go @@ -48,6 +48,10 @@ var _ = Describe("Kafka Controller", Ordered, func() { testKafkaManifest.Spec.Kraft[0].ControllerNodeCount = 4 Expect(k8sClient.Create(ctx, &testKafkaManifest)).ShouldNot(Succeed()) testKafkaManifest.Spec.Kraft[0].ControllerNodeCount = 3 + + testKafkaManifest.Spec.Version += ".1" + Expect(k8sClient.Create(ctx, &testKafkaManifest)).ShouldNot(Succeed()) + testKafkaManifest.Spec.Version = kafkaManifest.Spec.Version }) }) diff --git a/apis/clusters/v1beta1/opensearch_types.go b/apis/clusters/v1beta1/opensearch_types.go index a72968978..c092bb97c 100644 --- a/apis/clusters/v1beta1/opensearch_types.go +++ b/apis/clusters/v1beta1/opensearch_types.go @@ -49,7 +49,7 @@ type OpenSearchSpec struct { NotificationsPlugin bool `json:"notificationsPlugin,omitempty"` AnomalyDetectionPlugin bool `json:"anomalyDetectionPlugin,omitempty"` LoadBalancer bool `json:"loadBalancer,omitempty"` - ClusterManagerNodes []*ClusterManagerNodes `json:"clusterManagerNodes,omitempty"` + ClusterManagerNodes []*ClusterManagerNodes `json:"clusterManagerNodes"` IndexManagementPlugin bool `json:"indexManagementPlugin,omitempty"` AlertingPlugin bool `json:"alertingPlugin,omitempty"` BundledUseOnly bool `json:"bundledUseOnly,omitempty"` diff --git a/apis/clusters/v1beta1/opensearch_webhook.go b/apis/clusters/v1beta1/opensearch_webhook.go index d2992aa8a..9ef1a7569 100644 --- a/apis/clusters/v1beta1/opensearch_webhook.go +++ b/apis/clusters/v1beta1/opensearch_webhook.go @@ -212,6 +212,10 @@ func (osv *openSearchValidator) ValidateUpdate(ctx context.Context, old runtime. return fmt.Errorf("cannot assert object %v to openSearch", new.GetObjectKind()) } + if os.Status.ID == "" { + return osv.ValidateCreate(ctx, os) + } + opensearchlog.Info("validate update", "name", os.Name) // skip validation when we receive cluster specification update from the Instaclustr Console. @@ -229,10 +233,6 @@ func (osv *openSearchValidator) ValidateUpdate(ctx context.Context, old runtime. return nil } - if os.Status.ID == "" { - return osv.ValidateCreate(ctx, os) - } - err := os.Spec.validateUpdate(oldCluster.Spec) if err != nil { return err @@ -307,18 +307,18 @@ type specificOpenSearchDC struct { ReplicationFactor int } -func (oss *OpenSearchDataCentre) newImmutableFields() *immutableOpenSearchDCFields { +func (osdc *OpenSearchDataCentre) newImmutableFields() *immutableOpenSearchDCFields { return &immutableOpenSearchDCFields{ immutableDC{ - Name: oss.Name, - Region: oss.Region, - CloudProvider: oss.CloudProvider, - ProviderAccountName: oss.ProviderAccountName, - Network: oss.Network, + Name: osdc.Name, + Region: osdc.Region, + CloudProvider: osdc.CloudProvider, + ProviderAccountName: osdc.ProviderAccountName, + Network: osdc.Network, }, specificOpenSearchDC{ - PrivateLink: oss.PrivateLink, - ReplicationFactor: oss.ReplicationFactor, + PrivateLink: osdc.PrivateLink, + ReplicationFactor: osdc.ReplicationFactor, }, } } diff --git a/apis/clusters/v1beta1/opensearch_webhook_test.go b/apis/clusters/v1beta1/opensearch_webhook_test.go new file mode 100644 index 000000000..dd0820f03 --- /dev/null +++ b/apis/clusters/v1beta1/opensearch_webhook_test.go @@ -0,0 +1,286 @@ +package v1beta1 + +import ( + "context" + "os" + + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" + "k8s.io/apimachinery/pkg/util/yaml" + + "github.com/instaclustr/operator/pkg/models" +) + +var _ = Describe("Kafka Controller", Ordered, func() { + openSearchManifest := OpenSearch{} + testOpenSearchManifest := OpenSearch{} + + It("Reading kafka manifest", func() { + yfile, err := os.ReadFile("../../../controllers/clusters/datatest/opensearch_v1beta1.yaml") + Expect(err).Should(Succeed()) + + err = yaml.Unmarshal(yfile, &openSearchManifest) + Expect(err).Should(Succeed()) + testOpenSearchManifest = openSearchManifest + }) + + ctx := context.Background() + + When("apply a OpenSearch manifest", func() { + It("should test OpenSearch creation flow", func() { + testOpenSearchManifest.Spec.Description = "some description" + Expect(k8sClient.Create(ctx, &testOpenSearchManifest)).ShouldNot(Succeed()) + testOpenSearchManifest.Spec.Description = openSearchManifest.Spec.Description + + testOpenSearchManifest.Spec.TwoFactorDelete = []*TwoFactorDelete{openSearchManifest.Spec.TwoFactorDelete[0], openSearchManifest.Spec.TwoFactorDelete[0]} + Expect(k8sClient.Create(ctx, &testOpenSearchManifest)).ShouldNot(Succeed()) + testOpenSearchManifest.Spec.TwoFactorDelete = openSearchManifest.Spec.TwoFactorDelete + + testOpenSearchManifest.Spec.SLATier = "some SLATier that is not supported" + Expect(k8sClient.Create(ctx, &testOpenSearchManifest)).ShouldNot(Succeed()) + testOpenSearchManifest.Spec.SLATier = openSearchManifest.Spec.SLATier + + testOpenSearchManifest.Spec.DataCentres = []*OpenSearchDataCentre{} + Expect(k8sClient.Create(ctx, &testOpenSearchManifest)).ShouldNot(Succeed()) + testOpenSearchManifest.Spec.DataCentres = openSearchManifest.Spec.DataCentres + + prevDataNode := openSearchManifest.Spec.DataNodes[0] + testOpenSearchManifest.Spec.DataNodes = []*OpenSearchDataNodes{} + Expect(k8sClient.Create(ctx, &testOpenSearchManifest)).ShouldNot(Succeed()) + testOpenSearchManifest.Spec.DataNodes = []*OpenSearchDataNodes{prevDataNode} + + prevDC := *openSearchManifest.Spec.DataCentres[0] + testOpenSearchManifest.Spec.DataCentres[0].CloudProvider = "test" + Expect(k8sClient.Create(ctx, &testOpenSearchManifest)).ShouldNot(Succeed()) + + testOpenSearchManifest.Spec.DataCentres[0].CloudProvider = "AWS_VPC" + testOpenSearchManifest.Spec.DataCentres[0].Region = "test" + Expect(k8sClient.Create(ctx, &testOpenSearchManifest)).ShouldNot(Succeed()) + + testOpenSearchManifest.Spec.DataCentres[0].CloudProvider = "AZURE_AZ" + Expect(k8sClient.Create(ctx, &testOpenSearchManifest)).ShouldNot(Succeed()) + + testOpenSearchManifest.Spec.DataCentres[0].CloudProvider = "GCP" + Expect(k8sClient.Create(ctx, &testOpenSearchManifest)).ShouldNot(Succeed()) + testOpenSearchManifest.Spec.DataCentres[0] = &prevDC + + prevStringValue := openSearchManifest.Spec.DataCentres[0].ProviderAccountName + testOpenSearchManifest.Spec.DataCentres[0].ProviderAccountName = models.DefaultAccountName + Expect(k8sClient.Create(ctx, &testOpenSearchManifest)).ShouldNot(Succeed()) + testOpenSearchManifest.Spec.DataCentres[0].ProviderAccountName = prevStringValue + + providerSettings := openSearchManifest.Spec.DataCentres[0].CloudProviderSettings[0] + testOpenSearchManifest.Spec.DataCentres[0].CloudProviderSettings = []*CloudProviderSettings{providerSettings, providerSettings} + Expect(k8sClient.Create(ctx, &testOpenSearchManifest)).ShouldNot(Succeed()) + testOpenSearchManifest.Spec.DataCentres[0].CloudProviderSettings = []*CloudProviderSettings{providerSettings} + + testOpenSearchManifest.Spec.DataCentres[0].CloudProviderSettings[0].ResourceGroup = "test" + Expect(k8sClient.Create(ctx, &testOpenSearchManifest)).ShouldNot(Succeed()) + + prevStringValue = openSearchManifest.Spec.DataCentres[0].CloudProviderSettings[0].DiskEncryptionKey + testOpenSearchManifest.Spec.DataCentres[0].CloudProviderSettings[0].DiskEncryptionKey = "" + testOpenSearchManifest.Spec.DataCentres[0].CloudProviderSettings[0].CustomVirtualNetworkID = "test" + Expect(k8sClient.Create(ctx, &testOpenSearchManifest)).ShouldNot(Succeed()) + testOpenSearchManifest.Spec.DataCentres[0].CloudProviderSettings[0].ResourceGroup = "" + testOpenSearchManifest.Spec.DataCentres[0].CloudProviderSettings[0].CustomVirtualNetworkID = "" + testOpenSearchManifest.Spec.DataCentres[0].CloudProviderSettings[0].DiskEncryptionKey = prevStringValue + + prevStringValue = openSearchManifest.Spec.DataCentres[0].Network + testOpenSearchManifest.Spec.DataCentres[0].Network = "test/test" + Expect(k8sClient.Create(ctx, &testOpenSearchManifest)).ShouldNot(Succeed()) + testOpenSearchManifest.Spec.DataCentres[0].Network = prevStringValue + + testOpenSearchManifest.Spec.DataNodes[0].NodesNumber++ + Expect(k8sClient.Create(ctx, &testOpenSearchManifest)).ShouldNot(Succeed()) + testOpenSearchManifest.Spec.DataNodes[0].NodesNumber-- + + testOpenSearchManifest.Spec.DataCentres[0].ReplicationFactor++ + Expect(k8sClient.Create(ctx, &testOpenSearchManifest)).ShouldNot(Succeed()) + testOpenSearchManifest.Spec.DataCentres[0].ReplicationFactor-- + + testOpenSearchManifest.Spec.DataCentres[0].CloudProvider = "GCP" + testOpenSearchManifest.Spec.DataCentres[0].PrivateLink = true + testOpenSearchManifest.Spec.DataCentres[0].Region = "us-east1" + Expect(k8sClient.Create(ctx, &testOpenSearchManifest)).ShouldNot(Succeed()) + testOpenSearchManifest.Spec.DataCentres[0].CloudProvider = "AWS_VPC" + testOpenSearchManifest.Spec.DataCentres[0].PrivateLink = false + testOpenSearchManifest.Spec.DataCentres[0].Region = "US_EAST_1" + + testOpenSearchManifest.Spec.ResizeSettings[0].Concurrency++ + Expect(k8sClient.Create(ctx, &testOpenSearchManifest)).ShouldNot(Succeed()) + testOpenSearchManifest.Spec.ResizeSettings[0].Concurrency-- + + prevManagedNode := openSearchManifest.Spec.ClusterManagerNodes[0] + testOpenSearchManifest.Spec.ClusterManagerNodes = []*ClusterManagerNodes{prevManagedNode, prevManagedNode, prevManagedNode, prevManagedNode} + testOpenSearchManifest.Spec.ResizeSettings[0].Concurrency += 3 + Expect(k8sClient.Create(ctx, &testOpenSearchManifest)).ShouldNot(Succeed()) + testOpenSearchManifest.Spec.ResizeSettings[0].Concurrency -= 3 + testOpenSearchManifest.Spec.ClusterManagerNodes = []*ClusterManagerNodes{prevManagedNode} + + testOpenSearchManifest.Spec.Version += ".1" + Expect(k8sClient.Create(ctx, &testOpenSearchManifest)).ShouldNot(Succeed()) + testOpenSearchManifest.Spec.Version = openSearchManifest.Spec.Version + + }) + }) + + When("updating a OpenSearch manifest", func() { + It("should test OpenSearch update flow", func() { + testOpenSearchManifest.Status.State = models.RunningStatus + Expect(k8sClient.Create(ctx, &testOpenSearchManifest)).Should(Succeed()) + + patch := testOpenSearchManifest.NewPatch() + testOpenSearchManifest.Status.ID = models.CreatedEvent + Expect(k8sClient.Status().Patch(ctx, &testOpenSearchManifest, patch)).Should(Succeed()) + + testOpenSearchManifest.Spec.Name += "newValue" + Expect(k8sClient.Patch(ctx, &testOpenSearchManifest, patch)).ShouldNot(Succeed()) + testOpenSearchManifest.Spec.Name = openSearchManifest.Spec.Name + + testOpenSearchManifest.Spec.BundledUseOnly = !testOpenSearchManifest.Spec.BundledUseOnly + Expect(k8sClient.Patch(ctx, &testOpenSearchManifest, patch)).ShouldNot(Succeed()) + testOpenSearchManifest.Spec.BundledUseOnly = !testOpenSearchManifest.Spec.BundledUseOnly + + testOpenSearchManifest.Spec.ICUPlugin = !testOpenSearchManifest.Spec.ICUPlugin + Expect(k8sClient.Patch(ctx, &testOpenSearchManifest, patch)).ShouldNot(Succeed()) + testOpenSearchManifest.Spec.ICUPlugin = !testOpenSearchManifest.Spec.ICUPlugin + + testOpenSearchManifest.Spec.AsynchronousSearchPlugin = !testOpenSearchManifest.Spec.AsynchronousSearchPlugin + Expect(k8sClient.Patch(ctx, &testOpenSearchManifest, patch)).ShouldNot(Succeed()) + testOpenSearchManifest.Spec.AsynchronousSearchPlugin = !testOpenSearchManifest.Spec.AsynchronousSearchPlugin + + testOpenSearchManifest.Spec.KNNPlugin = !testOpenSearchManifest.Spec.KNNPlugin + Expect(k8sClient.Patch(ctx, &testOpenSearchManifest, patch)).ShouldNot(Succeed()) + testOpenSearchManifest.Spec.KNNPlugin = !testOpenSearchManifest.Spec.KNNPlugin + + testOpenSearchManifest.Spec.ReportingPlugin = !testOpenSearchManifest.Spec.ReportingPlugin + Expect(k8sClient.Patch(ctx, &testOpenSearchManifest, patch)).ShouldNot(Succeed()) + testOpenSearchManifest.Spec.ReportingPlugin = !testOpenSearchManifest.Spec.ReportingPlugin + + testOpenSearchManifest.Spec.SQLPlugin = !testOpenSearchManifest.Spec.SQLPlugin + Expect(k8sClient.Patch(ctx, &testOpenSearchManifest, patch)).ShouldNot(Succeed()) + testOpenSearchManifest.Spec.SQLPlugin = !testOpenSearchManifest.Spec.SQLPlugin + + testOpenSearchManifest.Spec.NotificationsPlugin = !testOpenSearchManifest.Spec.NotificationsPlugin + Expect(k8sClient.Patch(ctx, &testOpenSearchManifest, patch)).ShouldNot(Succeed()) + testOpenSearchManifest.Spec.NotificationsPlugin = !testOpenSearchManifest.Spec.NotificationsPlugin + + testOpenSearchManifest.Spec.AnomalyDetectionPlugin = !testOpenSearchManifest.Spec.AnomalyDetectionPlugin + Expect(k8sClient.Patch(ctx, &testOpenSearchManifest, patch)).ShouldNot(Succeed()) + testOpenSearchManifest.Spec.AnomalyDetectionPlugin = !testOpenSearchManifest.Spec.AnomalyDetectionPlugin + + testOpenSearchManifest.Spec.LoadBalancer = !testOpenSearchManifest.Spec.LoadBalancer + Expect(k8sClient.Patch(ctx, &testOpenSearchManifest, patch)).ShouldNot(Succeed()) + testOpenSearchManifest.Spec.LoadBalancer = !testOpenSearchManifest.Spec.LoadBalancer + + testOpenSearchManifest.Spec.IndexManagementPlugin = !testOpenSearchManifest.Spec.IndexManagementPlugin + Expect(k8sClient.Patch(ctx, &testOpenSearchManifest, patch)).ShouldNot(Succeed()) + testOpenSearchManifest.Spec.IndexManagementPlugin = !testOpenSearchManifest.Spec.IndexManagementPlugin + + testOpenSearchManifest.Spec.AlertingPlugin = !testOpenSearchManifest.Spec.AlertingPlugin + Expect(k8sClient.Patch(ctx, &testOpenSearchManifest, patch)).ShouldNot(Succeed()) + testOpenSearchManifest.Spec.AlertingPlugin = !testOpenSearchManifest.Spec.AlertingPlugin + + testOpenSearchManifest.Spec.PCICompliance = !testOpenSearchManifest.Spec.PCICompliance + Expect(k8sClient.Patch(ctx, &testOpenSearchManifest, patch)).ShouldNot(Succeed()) + testOpenSearchManifest.Spec.PCICompliance = !testOpenSearchManifest.Spec.PCICompliance + + testOpenSearchManifest.Spec.PrivateNetworkCluster = !testOpenSearchManifest.Spec.PrivateNetworkCluster + Expect(k8sClient.Patch(ctx, &testOpenSearchManifest, patch)).ShouldNot(Succeed()) + testOpenSearchManifest.Spec.PrivateNetworkCluster = !testOpenSearchManifest.Spec.PrivateNetworkCluster + + prevStringValue := openSearchManifest.Spec.SLATier + testOpenSearchManifest.Spec.SLATier = "test" + Expect(k8sClient.Patch(ctx, &testOpenSearchManifest, patch)).ShouldNot(Succeed()) + testOpenSearchManifest.Spec.SLATier = prevStringValue + + prevTwoFactorDelete := testOpenSearchManifest.Spec.TwoFactorDelete + testOpenSearchManifest.Spec.TwoFactorDelete = []*TwoFactorDelete{prevTwoFactorDelete[0], prevTwoFactorDelete[0]} + Expect(k8sClient.Patch(ctx, &testOpenSearchManifest, patch)).ShouldNot(Succeed()) + testOpenSearchManifest.Spec.TwoFactorDelete = []*TwoFactorDelete{prevTwoFactorDelete[0]} + + testOpenSearchManifest.Spec.TwoFactorDelete = []*TwoFactorDelete{} + Expect(k8sClient.Patch(ctx, &testOpenSearchManifest, patch)).ShouldNot(Succeed()) + testOpenSearchManifest.Spec.TwoFactorDelete = []*TwoFactorDelete{prevTwoFactorDelete[0]} + + prevStringValue = openSearchManifest.Spec.TwoFactorDelete[0].Email + testOpenSearchManifest.Spec.TwoFactorDelete[0].Email = "test" + Expect(k8sClient.Patch(ctx, &testOpenSearchManifest, patch)).ShouldNot(Succeed()) + testOpenSearchManifest.Spec.TwoFactorDelete[0].Email = prevStringValue + + By("changing datacentres fields") + + prevDCs := openSearchManifest.Spec.DataCentres + testOpenSearchManifest.Spec.DataCentres = []*OpenSearchDataCentre{prevDCs[0], prevDCs[0]} + Expect(k8sClient.Patch(ctx, &testOpenSearchManifest, patch)).ShouldNot(Succeed()) + testOpenSearchManifest.Spec.DataCentres = []*OpenSearchDataCentre{prevDCs[0]} + + prevStringValue = prevDCs[0].Name + testOpenSearchManifest.Spec.DataCentres[0].Name = "test" + Expect(k8sClient.Patch(ctx, &testOpenSearchManifest, patch)).ShouldNot(Succeed()) + testOpenSearchManifest.Spec.DataCentres[0].Name = prevStringValue + + prevStringValue = prevDCs[0].Region + testOpenSearchManifest.Spec.DataCentres[0].Region = "test" + Expect(k8sClient.Patch(ctx, &testOpenSearchManifest, patch)).ShouldNot(Succeed()) + testOpenSearchManifest.Spec.DataCentres[0].Region = prevStringValue + + prevStringValue = prevDCs[0].CloudProvider + testOpenSearchManifest.Spec.DataCentres[0].CloudProvider = "test" + Expect(k8sClient.Patch(ctx, &testOpenSearchManifest, patch)).ShouldNot(Succeed()) + testOpenSearchManifest.Spec.DataCentres[0].CloudProvider = prevStringValue + + prevStringValue = prevDCs[0].ProviderAccountName + testOpenSearchManifest.Spec.DataCentres[0].ProviderAccountName = "test" + Expect(k8sClient.Patch(ctx, &testOpenSearchManifest, patch)).ShouldNot(Succeed()) + testOpenSearchManifest.Spec.DataCentres[0].ProviderAccountName = prevStringValue + + prevStringValue = prevDCs[0].Network + testOpenSearchManifest.Spec.DataCentres[0].Network = "test" + Expect(k8sClient.Patch(ctx, &testOpenSearchManifest, patch)).ShouldNot(Succeed()) + testOpenSearchManifest.Spec.DataCentres[0].Network = prevStringValue + + testOpenSearchManifest.Spec.DataCentres[0].PrivateLink = !testOpenSearchManifest.Spec.DataCentres[0].PrivateLink + Expect(k8sClient.Patch(ctx, &testOpenSearchManifest, patch)).ShouldNot(Succeed()) + testOpenSearchManifest.Spec.DataCentres[0].PrivateLink = !testOpenSearchManifest.Spec.DataCentres[0].PrivateLink + + testOpenSearchManifest.Spec.DataCentres[0].ReplicationFactor += 1 + Expect(k8sClient.Patch(ctx, &testOpenSearchManifest, patch)).ShouldNot(Succeed()) + testOpenSearchManifest.Spec.DataCentres[0].ReplicationFactor -= 1 + + prevCloudProviderSettings := openSearchManifest.Spec.DataCentres[0].CloudProviderSettings + testOpenSearchManifest.Spec.DataCentres[0].CloudProviderSettings = []*CloudProviderSettings{prevCloudProviderSettings[0], prevCloudProviderSettings[0]} + Expect(k8sClient.Patch(ctx, &testOpenSearchManifest, patch)).ShouldNot(Succeed()) + testOpenSearchManifest.Spec.DataCentres[0].CloudProviderSettings = []*CloudProviderSettings{prevCloudProviderSettings[0]} + + prevStringValue = openSearchManifest.Spec.DataCentres[0].CloudProviderSettings[0].DiskEncryptionKey + testOpenSearchManifest.Spec.DataCentres[0].CloudProviderSettings[0].DiskEncryptionKey = "test" + Expect(k8sClient.Patch(ctx, &testOpenSearchManifest, patch)).ShouldNot(Succeed()) + testOpenSearchManifest.Spec.DataCentres[0].CloudProviderSettings[0].DiskEncryptionKey = prevStringValue + + prevStringValue = openSearchManifest.Spec.DataCentres[0].CloudProviderSettings[0].ResourceGroup + testOpenSearchManifest.Spec.DataCentres[0].CloudProviderSettings[0].ResourceGroup = "test" + Expect(k8sClient.Patch(ctx, &testOpenSearchManifest, patch)).ShouldNot(Succeed()) + testOpenSearchManifest.Spec.DataCentres[0].CloudProviderSettings[0].ResourceGroup = prevStringValue + + prevStringValue = openSearchManifest.Spec.DataCentres[0].CloudProviderSettings[0].CustomVirtualNetworkID + testOpenSearchManifest.Spec.DataCentres[0].CloudProviderSettings[0].CustomVirtualNetworkID = "test" + Expect(k8sClient.Patch(ctx, &testOpenSearchManifest, patch)).ShouldNot(Succeed()) + testOpenSearchManifest.Spec.DataCentres[0].CloudProviderSettings[0].CustomVirtualNetworkID = prevStringValue + + testOpenSearchManifest.Spec.DataCentres[0].Tags["test"] = "test" + Expect(k8sClient.Patch(ctx, &testOpenSearchManifest, patch)).ShouldNot(Succeed()) + delete(testOpenSearchManifest.Spec.DataCentres[0].Tags, "test") + + delete(testOpenSearchManifest.Spec.DataCentres[0].Tags, "tag") + Expect(k8sClient.Patch(ctx, &testOpenSearchManifest, patch)).ShouldNot(Succeed()) + testOpenSearchManifest.Spec.DataCentres[0].Tags["tag"] = "oneTag" + + testOpenSearchManifest.Spec.DataCentres[0].Tags["tag"] = "test" + Expect(k8sClient.Patch(ctx, &testOpenSearchManifest, patch)).ShouldNot(Succeed()) + testOpenSearchManifest.Spec.DataCentres[0].Tags["tag"] = "oneTag" + + }) + + }) +}) diff --git a/apis/clusters/v1beta1/webhook_suite_test.go b/apis/clusters/v1beta1/webhook_suite_test.go index b83da4bcf..480ada4e7 100644 --- a/apis/clusters/v1beta1/webhook_suite_test.go +++ b/apis/clusters/v1beta1/webhook_suite_test.go @@ -27,6 +27,8 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" + k8sappsv1 "k8s.io/api/apps/v1" + k8scorev1 "k8s.io/api/core/v1" admissionv1beta1 "k8s.io/api/admission/v1beta1" //+kubebuilder:scaffold:imports @@ -79,6 +81,12 @@ var _ = BeforeSuite(func() { err = AddToScheme(scheme) Expect(err).NotTo(HaveOccurred()) + err = k8scorev1.AddToScheme(scheme) + Expect(err).NotTo(HaveOccurred()) + + err = k8sappsv1.AddToScheme(scheme) + Expect(err).NotTo(HaveOccurred()) + err = admissionv1beta1.AddToScheme(scheme) Expect(err).NotTo(HaveOccurred()) @@ -110,7 +118,7 @@ var _ = BeforeSuite(func() { err = (&Redis{}).SetupWebhookWithManager(mgr, nil) Expect(err).NotTo(HaveOccurred()) - err = (&OpenSearch{}).SetupWebhookWithManager(mgr, nil) + err = (&OpenSearch{}).SetupWebhookWithManager(mgr, api) Expect(err).NotTo(HaveOccurred()) err = (&Kafka{}).SetupWebhookWithManager(mgr, api) diff --git a/config/crd/bases/clusters.instaclustr.com_opensearches.yaml b/config/crd/bases/clusters.instaclustr.com_opensearches.yaml index 7ba8cc888..01a4d24db 100644 --- a/config/crd/bases/clusters.instaclustr.com_opensearches.yaml +++ b/config/crd/bases/clusters.instaclustr.com_opensearches.yaml @@ -263,6 +263,8 @@ spec: type: array version: type: string + required: + - clusterManagerNodes type: object status: description: OpenSearchStatus defines the observed state of OpenSearch diff --git a/controllers/clusters/datatest/kafka_v1beta1.yaml b/controllers/clusters/datatest/kafka_v1beta1.yaml index 4d73b5344..9f0668542 100644 --- a/controllers/clusters/datatest/kafka_v1beta1.yaml +++ b/controllers/clusters/datatest/kafka_v1beta1.yaml @@ -7,7 +7,7 @@ metadata: defaulter: webhook spec: name: "kafka" - version: "2.8.2" + version: 1.0.0 pciCompliance: true replicationFactor: 3 partitionsNumber: 3 diff --git a/controllers/clusters/datatest/opensearch_v1beta1.yaml b/controllers/clusters/datatest/opensearch_v1beta1.yaml index 2d861038d..29706b944 100644 --- a/controllers/clusters/datatest/opensearch_v1beta1.yaml +++ b/controllers/clusters/datatest/opensearch_v1beta1.yaml @@ -7,13 +7,17 @@ metadata: defaulter: webhook spec: alertingPlugin: false + bundledUseOnly: false anomalyDetectionPlugin: false asynchronousSearchPlugin: false + twoFactorDelete: + - email: "emailTEST" + phone: "phoneTEST" # userRef: # name: test-user # namespace: default clusterManagerNodes: - - dedicatedManager: false + - dedicatedManager: true nodeSize: SRH-DEV-t4g.small-5 dataCentres: - cloudProvider: AWS_VPC @@ -22,9 +26,17 @@ spec: replicationFactor: 3 privateLink: false region: US_EAST_1 -# dataNodes: -# - nodeNumber: 3 -# nodeSize: SRH-DEV-t4g.small-5 + accountName: "Custom" + cloudProviderSettings: + - diskEncryptionKey: "123e4567-e89b-12d3-a456-426614174000" + tags: + tag: "oneTag" + tag2: "twoTags" + resizeSettings: + - concurrency: 1 + dataNodes: + - nodesNumber: 3 + nodeSize: SRH-DEV-t4g.small-5 icuPlugin: false indexManagementPlugin: true knnPlugin: false @@ -35,7 +47,7 @@ spec: # - nodeSize: SRH-DEV-t4g.small-5 # oidcProvider: '' # version: opensearch-dashboards:2.5.0 - version: 2.5.0 + version: 1.0.0 pciCompliance: false privateNetworkCluster: false reportingPlugin: false diff --git a/pkg/instaclustr/mock/appversionsmock/models.go b/pkg/instaclustr/mock/appversionsmock/models.go index efc4ed1da..9f4e9d42d 100644 --- a/pkg/instaclustr/mock/appversionsmock/models.go +++ b/pkg/instaclustr/mock/appversionsmock/models.go @@ -15,5 +15,14 @@ func NewInstAPI() *mockClient { } func (c *mockClient) ListAppVersions(app string) ([]*models.AppVersions, error) { - return []*models.AppVersions{{Application: app, Versions: []string{"1.0.0"}}}, nil + versions := []string{"1.0.0"} + + switch app { + case models.OpenSearchAppKind: + return []*models.AppVersions{{Application: models.OpenSearchAppType, Versions: versions}}, nil + case models.KafkaAppKind: + return []*models.AppVersions{{Application: models.KafkaAppType, Versions: versions}}, nil + } + + return []*models.AppVersions{{Application: app, Versions: versions}}, nil }