diff --git a/apis/clusters/v1beta1/opensearch_types.go b/apis/clusters/v1beta1/opensearch_types.go index b471405a5..959e60f9e 100644 --- a/apis/clusters/v1beta1/opensearch_types.go +++ b/apis/clusters/v1beta1/opensearch_types.go @@ -31,7 +31,7 @@ import ( // +kubebuilder:object:generate:=false type OpenSearchNodeTypes interface { - OpenSearchDataNodes | OpenSearchDashboards | ClusterManagerNodes + OpenSearchDataNodes | OpenSearchDashboards | ClusterManagerNodes | OpenSearchIngestNodes } // OpenSearchSpec defines the desired state of OpenSearch @@ -56,6 +56,8 @@ type OpenSearchSpec struct { UserRefs []*UserReference `json:"userRefs,omitempty"` //+kubuilder:validation:MaxItems:=1 ResizeSettings []*ResizeSettings `json:"resizeSettings,omitempty"` + //+kubuilder:validation:MaxItems:=1 + IngestNodes []*OpenSearchIngestNodes `json:"ingestNodes,omitempty"` } type OpenSearchDataCentre struct { @@ -88,6 +90,11 @@ type ClusterManagerNodes struct { DedicatedManager bool `json:"dedicatedManager"` } +type OpenSearchIngestNodes struct { + NodeSize string `json:"nodeSize"` + NodeCount int `json:"nodeCount"` +} + func (oss *OpenSearchSpec) ToInstAPI() *models.OpenSearchCluster { return &models.OpenSearchCluster{ DataNodes: oss.dataNodesToInstAPI(), @@ -113,6 +120,7 @@ func (oss *OpenSearchSpec) ToInstAPI() *models.OpenSearchCluster { SLATier: oss.SLATier, AlertingPlugin: oss.AlertingPlugin, ResizeSettings: resizeSettingsToInstAPI(oss.ResizeSettings), + IngestNodes: oss.ingestNodesToInstAPI(), } } @@ -211,6 +219,17 @@ func (oss *OpenSearchSpec) dataNodesToInstAPI() (iDataNodes []*models.OpenSearch return } +func (oss *OpenSearchSpec) ingestNodesToInstAPI() (iIngestNodes []*models.OpenSearchIngestNodes) { + for _, ingestNode := range oss.IngestNodes { + iIngestNodes = append(iIngestNodes, &models.OpenSearchIngestNodes{ + NodeSize: ingestNode.NodeSize, + NodeCount: ingestNode.NodeCount, + }) + } + + return +} + func (oss *OpenSearch) FromInstAPI(iData []byte) (*OpenSearch, error) { iOpenSearch := &models.OpenSearchCluster{} err := json.Unmarshal(iData, iOpenSearch) @@ -253,6 +272,7 @@ func (oss *OpenSearchSpec) FromInstAPI(iOpenSearch *models.OpenSearchCluster) Op AlertingPlugin: oss.AlertingPlugin, BundledUseOnly: oss.BundledUseOnly, ResizeSettings: resizeSettingsFromInstAPI(iOpenSearch.ResizeSettings), + IngestNodes: oss.IngestNodesFromInstAPI(iOpenSearch.IngestNodes), } } @@ -339,6 +359,16 @@ func (oss *OpenSearchSpec) DataNodesFromInstAPI(iDataNodes []*models.OpenSearchD return } +func (oss *OpenSearchSpec) IngestNodesFromInstAPI(iIngestNodes []*models.OpenSearchIngestNodes) (ingestNodes []*OpenSearchIngestNodes) { + for _, iNode := range iIngestNodes { + ingestNodes = append(ingestNodes, &OpenSearchIngestNodes{ + NodeSize: iNode.NodeSize, + NodeCount: iNode.NodeCount, + }) + } + return +} + func (oss *OpenSearchSpec) DashboardsFromInstAPI(iDashboards []*models.OpenSearchDashboards) (dashboards []*OpenSearchDashboards) { for _, iDashboard := range iDashboards { dashboards = append(dashboards, &OpenSearchDashboards{ @@ -396,7 +426,8 @@ func (a *OpenSearchSpec) IsEqual(b OpenSearchSpec) bool { a.IndexManagementPlugin == b.IndexManagementPlugin && a.AlertingPlugin == b.AlertingPlugin && a.BundledUseOnly == b.BundledUseOnly && - a.areDCsEqual(b.DataCentres) + a.areDCsEqual(b.DataCentres) && + areOpenSearchSettingsEqual[OpenSearchIngestNodes](a.IngestNodes, b.IngestNodes) } func (oss *OpenSearchSpec) areDCsEqual(b []*OpenSearchDataCentre) bool { @@ -473,10 +504,11 @@ func areOpenSearchSettingsEqual[T OpenSearchNodeTypes](a, b []*T) bool { func (oss *OpenSearchSpec) ToInstAPIUpdate() models.OpenSearchInstAPIUpdateRequest { return models.OpenSearchInstAPIUpdateRequest{ - DataNodes: oss.dataNodesToInstAPI(), - OpenSearchDashboards: oss.dashboardsToInstAPI(), - ClusterManagerNodes: oss.clusterManagerNodesToInstAPI(), - ResizeSettings: resizeSettingsToInstAPI(oss.ResizeSettings), + DataNodes: oss.dataNodesToInstAPI(), + OpenSearchDashboards: oss.dashboardsToInstAPI(), + ClusterManagerNodes: oss.clusterManagerNodesToInstAPI(), + ResizeSettings: resizeSettingsToInstAPI(oss.ResizeSettings), + OpenSearchIngestNodes: oss.ingestNodesToInstAPI(), } } diff --git a/apis/clusters/v1beta1/zz_generated.deepcopy.go b/apis/clusters/v1beta1/zz_generated.deepcopy.go index eb4beebbd..8346d5ca2 100644 --- a/apis/clusters/v1beta1/zz_generated.deepcopy.go +++ b/apis/clusters/v1beta1/zz_generated.deepcopy.go @@ -1407,6 +1407,21 @@ func (in *OpenSearchDataNodes) DeepCopy() *OpenSearchDataNodes { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *OpenSearchIngestNodes) DeepCopyInto(out *OpenSearchIngestNodes) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OpenSearchIngestNodes. +func (in *OpenSearchIngestNodes) DeepCopy() *OpenSearchIngestNodes { + if in == nil { + return nil + } + out := new(OpenSearchIngestNodes) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *OpenSearchList) DeepCopyInto(out *OpenSearchList) { *out = *in @@ -1540,6 +1555,17 @@ func (in *OpenSearchSpec) DeepCopyInto(out *OpenSearchSpec) { } } } + if in.IngestNodes != nil { + in, out := &in.IngestNodes, &out.IngestNodes + *out = make([]*OpenSearchIngestNodes, len(*in)) + for i := range *in { + if (*in)[i] != nil { + in, out := &(*in)[i], &(*out)[i] + *out = new(OpenSearchIngestNodes) + **out = **in + } + } + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new OpenSearchSpec. diff --git a/config/crd/bases/clusters.instaclustr.com_opensearches.yaml b/config/crd/bases/clusters.instaclustr.com_opensearches.yaml index c88f405ec..66c626ebe 100644 --- a/config/crd/bases/clusters.instaclustr.com_opensearches.yaml +++ b/config/crd/bases/clusters.instaclustr.com_opensearches.yaml @@ -127,6 +127,18 @@ spec: type: boolean indexManagementPlugin: type: boolean + ingestNodes: + items: + properties: + nodeCount: + type: integer + nodeSize: + type: string + required: + - nodeCount + - nodeSize + type: object + type: array knnPlugin: type: boolean loadBalancer: diff --git a/config/samples/clusters_v1beta1_opensearch.yaml b/config/samples/clusters_v1beta1_opensearch.yaml index beb1ed157..c7ddc75a6 100644 --- a/config/samples/clusters_v1beta1_opensearch.yaml +++ b/config/samples/clusters_v1beta1_opensearch.yaml @@ -30,6 +30,10 @@ spec: replicationFactor: 3 privateLink: false region: US_EAST_1 + ingestNodes: +# - nodeSize: SRH-DI-PRD-m6g.large-10 + - nodeSize: SRH-DI-PRD-m6g.xlarge-10 + nodeCount: 3 # dataNodes: # - nodeNumber: 3 # nodeSize: SRH-DEV-t4g.small-5 @@ -50,4 +54,4 @@ spec: sqlPlugin: false # resizeSettings: # - notifySupportContacts: false -# concurrency: 3 +# concurrency: 3 \ No newline at end of file diff --git a/controllers/clusterresources/nodereload_controller.go b/controllers/clusterresources/nodereload_controller.go index 7a8a3d3e2..9640fb5e4 100644 --- a/controllers/clusterresources/nodereload_controller.go +++ b/controllers/clusterresources/nodereload_controller.go @@ -177,7 +177,6 @@ func (r *NodeReloadReconciler) Reconcile(ctx context.Context, req ctrl.Request) if nodeReloadStatus.Status != nodeReloadOperationStatusCompleted { l.Info("Node Reload operation is not completed yet, please wait a few minutes", - "nodeID", nrs.Status.NodeInProgress, "status", nrs.Status, ) @@ -185,10 +184,10 @@ func (r *NodeReloadReconciler) Reconcile(ctx context.Context, req ctrl.Request) } l.Info("The node has been successfully reloaded", - "Node ID", nrs.Status.NodeInProgress.ID, + "status", nrs.Status, ) r.EventRecorder.Eventf(nrs, models.Normal, models.UpdatedEvent, - "Node %s has been successfully reloaded", nrs.Status.NodeInProgress.ID, + "Node %s has been successfully reloaded", nrs.Status, ) patch = nrs.NewPatch() diff --git a/pkg/models/opensearch_apiv2.go b/pkg/models/opensearch_apiv2.go index 51abc7776..cd5806cf7 100644 --- a/pkg/models/opensearch_apiv2.go +++ b/pkg/models/opensearch_apiv2.go @@ -18,29 +18,35 @@ package models type OpenSearchCluster struct { ClusterStatus `json:",inline"` - DataNodes []*OpenSearchDataNodes `json:"dataNodes,omitempty"` - PCIComplianceMode bool `json:"pciComplianceMode"` - ICUPlugin bool `json:"icuPlugin"` - OpenSearchVersion string `json:"opensearchVersion"` - AsynchronousSearchPlugin bool `json:"asynchronousSearchPlugin"` - TwoFactorDelete []*TwoFactorDelete `json:"twoFactorDelete,omitempty"` - KNNPlugin bool `json:"knnPlugin"` - OpenSearchDashboards []*OpenSearchDashboards `json:"opensearchDashboards,omitempty"` - ReportingPlugin bool `json:"reportingPlugin"` - SQLPlugin bool `json:"sqlPlugin"` - NotificationsPlugin bool `json:"notificationsPlugin"` - DataCentres []*OpenSearchDataCentre `json:"dataCentres"` - AnomalyDetectionPlugin bool `json:"anomalyDetectionPlugin"` - LoadBalancer bool `json:"loadBalancer"` - PrivateNetworkCluster bool `json:"privateNetworkCluster"` - Name string `json:"name"` - BundledUseOnly bool `json:"bundledUseOnly"` - ClusterManagerNodes []*ClusterManagerNodes `json:"clusterManagerNodes"` - IndexManagementPlugin bool `json:"indexManagementPlugin"` - SLATier string `json:"slaTier,omitempty"` - AlertingPlugin bool `json:"alertingPlugin"` - ResizeSettings []*ResizeSettings `json:"resizeSettings,omitempty"` - Description string `json:"description,omitempty"` + DataNodes []*OpenSearchDataNodes `json:"dataNodes,omitempty"` + PCIComplianceMode bool `json:"pciComplianceMode"` + ICUPlugin bool `json:"icuPlugin"` + OpenSearchVersion string `json:"opensearchVersion"` + AsynchronousSearchPlugin bool `json:"asynchronousSearchPlugin"` + TwoFactorDelete []*TwoFactorDelete `json:"twoFactorDelete,omitempty"` + KNNPlugin bool `json:"knnPlugin"` + OpenSearchDashboards []*OpenSearchDashboards `json:"opensearchDashboards,omitempty"` + ReportingPlugin bool `json:"reportingPlugin"` + SQLPlugin bool `json:"sqlPlugin"` + NotificationsPlugin bool `json:"notificationsPlugin"` + DataCentres []*OpenSearchDataCentre `json:"dataCentres"` + AnomalyDetectionPlugin bool `json:"anomalyDetectionPlugin"` + LoadBalancer bool `json:"loadBalancer"` + PrivateNetworkCluster bool `json:"privateNetworkCluster"` + Name string `json:"name"` + BundledUseOnly bool `json:"bundledUseOnly"` + ClusterManagerNodes []*ClusterManagerNodes `json:"clusterManagerNodes"` + IndexManagementPlugin bool `json:"indexManagementPlugin"` + SLATier string `json:"slaTier,omitempty"` + AlertingPlugin bool `json:"alertingPlugin"` + ResizeSettings []*ResizeSettings `json:"resizeSettings,omitempty"` + Description string `json:"description,omitempty"` + IngestNodes []*OpenSearchIngestNodes `json:"ingestNodes,omitempty"` +} + +type OpenSearchIngestNodes struct { + NodeSize string `json:"nodeSize"` + NodeCount int `json:"nodeCount"` } type OpenSearchDataNodes struct { @@ -66,8 +72,9 @@ type ClusterManagerNodes struct { } type OpenSearchInstAPIUpdateRequest struct { - DataNodes []*OpenSearchDataNodes `json:"dataNodes,omitempty"` - OpenSearchDashboards []*OpenSearchDashboards `json:"opensearchDashboards,omitempty"` - ClusterManagerNodes []*ClusterManagerNodes `json:"clusterManagerNodes"` - ResizeSettings []*ResizeSettings `json:"resizeSettings,omitempty"` + DataNodes []*OpenSearchDataNodes `json:"dataNodes,omitempty"` + OpenSearchDashboards []*OpenSearchDashboards `json:"opensearchDashboards,omitempty"` + ClusterManagerNodes []*ClusterManagerNodes `json:"clusterManagerNodes"` + ResizeSettings []*ResizeSettings `json:"resizeSettings,omitempty"` + OpenSearchIngestNodes []*OpenSearchIngestNodes `json:"ingestNodes,omitempty"` }