Skip to content

Commit

Permalink
opensearch cr status was updated
Browse files Browse the repository at this point in the history
  • Loading branch information
Bohdan Siryk authored and Bohdan Siryk committed Jan 26, 2024
1 parent b0b9418 commit b3b20e7
Show file tree
Hide file tree
Showing 23 changed files with 572 additions and 265 deletions.
6 changes: 3 additions & 3 deletions apis/clusters/v1beta1/cadence_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ type BundledKafkaSpec struct {
}

type BundledOpenSearchSpec struct {
NodeSize string `json:"nodeSize"`
ReplicationFactor int `json:"replicationFactor"`
Network string `json:"network"`
NodeSize string `json:"nodeSize"`
NumberOfRacks int `json:"numberOfRacks"`
Network string `json:"network"`
}

// CadenceSpec defines the desired state of Cadence
Expand Down
2 changes: 1 addition & 1 deletion apis/clusters/v1beta1/cadence_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ func (o *BundledOpenSearchSpec) validate() error {
return fmt.Errorf("the provided CIDR: %s must contain four dot separated parts and form the Private IP address. All bits in the host part of the CIDR must be 0. Suffix must be between 16-28. %v", o.Network, err)
}

err = validateReplicationFactor(models.OpenSearchReplicationFactors, o.ReplicationFactor)
err = validateOpenSearchNumberOfRacks(o.NumberOfRacks)
if err != nil {
return err
}
Expand Down
86 changes: 86 additions & 0 deletions apis/clusters/v1beta1/generic_status.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
package v1beta1

import (
"k8s.io/utils/strings/slices"

"github.com/instaclustr/operator/apis/clusterresources/v1beta1"
"github.com/instaclustr/operator/pkg/models"
)

type GenericStatus struct {
ID string `json:"id,omitempty"`
State string `json:"state,omitempty"`
CurrentClusterOperationStatus string `json:"currentClusterOperationStatus,omitempty"`

MaintenanceEvents []*v1beta1.ClusteredMaintenanceEventStatus `json:"maintenanceEvents,omitempty"`
}

func (s *GenericStatus) Equals(o *GenericStatus) bool {
return s.ID == o.ID &&
s.State == o.State &&
s.CurrentClusterOperationStatus == o.CurrentClusterOperationStatus
}

func (s *GenericStatus) FromInstAPI(instaModel *models.GenericClusterFields) {
s.ID = instaModel.ID
s.State = instaModel.Status
s.CurrentClusterOperationStatus = instaModel.CurrentClusterOperationStatus
}

func (s *GenericStatus) MaintenanceEventsEqual(events []*v1beta1.ClusteredMaintenanceEventStatus) bool {
if len(s.MaintenanceEvents) != len(events) {
return false
}

for i := range events {
if !areEventStatusesEqual(events[i], s.MaintenanceEvents[i]) {
return false
}
}

return true
}

type GenericDataCentreStatus struct {
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Status string `json:"status,omitempty"`

ResizeOperations []*ResizeOperation `json:"resizeOperations,omitempty"`
}

func (s *GenericDataCentreStatus) Equals(o *GenericDataCentreStatus) bool {
return s.Name == o.Name &&
s.Status == o.Status &&
s.ID == o.ID
}

type Node struct {
ID string `json:"id,omitempty"`
Size string `json:"size,omitempty"`
PublicAddress string `json:"publicAddress,omitempty"`
PrivateAddress string `json:"privateAddress,omitempty"`
Status string `json:"status,omitempty"`
Roles []string `json:"roles,omitempty"`
Rack string `json:"rack,omitempty"`
}

func (n *Node) Equals(o *Node) bool {
return n.ID == o.ID &&
n.Size == o.Size &&
n.PublicAddress == o.PublicAddress &&
n.PrivateAddress == o.PrivateAddress &&
n.Status == o.Status &&
n.Rack == o.Rack &&
slices.Equal(n.Roles, o.Roles)
}

func (n *Node) FromInstAPI(instaModel *models.Node) {
n.ID = instaModel.ID
n.Size = instaModel.Size
n.PublicAddress = instaModel.PublicAddress
n.PrivateAddress = instaModel.PrivateAddress
n.Status = instaModel.Status
n.Roles = instaModel.Roles
n.Rack = instaModel.Rack
}
Loading

0 comments on commit b3b20e7

Please sign in to comment.