Skip to content

Commit

Permalink
issue-607, crud of opensearch and redis users were moved to reconcile
Browse files Browse the repository at this point in the history
  • Loading branch information
Bohdan Siryk authored and Bohdan Siryk committed Nov 15, 2023
1 parent 3357738 commit a4fd7f4
Show file tree
Hide file tree
Showing 12 changed files with 184 additions and 503 deletions.
8 changes: 8 additions & 0 deletions apis/clusterresources/v1beta1/opensearchuser_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,14 @@ func (u *OpenSearchUser) GetDeletionFinalizer() string {
return models.DeletionFinalizer + "_" + u.Namespace + "_" + u.Name
}

func (u *OpenSearchUser) GetClusterEvents() map[string]string {
return u.Status.ClustersEvents
}

func (u *OpenSearchUser) SetClusterEvents(events map[string]string) {
u.Status.ClustersEvents = events
}

func init() {
SchemeBuilder.Register(&OpenSearchUser{}, &OpenSearchUserList{})
}
8 changes: 8 additions & 0 deletions apis/clusterresources/v1beta1/redisuser_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@ func (r *RedisUser) NewPatch() client.Patch {
return client.MergeFrom(old)
}

func (r *RedisUser) GetClusterEvents() map[string]string {
return r.Status.ClustersEvents
}

func (r *RedisUser) SetClusterEvents(events map[string]string) {
r.Status.ClustersEvents = events
}

func init() {
SchemeBuilder.Register(&RedisUser{}, &RedisUserList{})
}
29 changes: 27 additions & 2 deletions apis/clusters/v1beta1/opensearch_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ type OpenSearchSpec struct {
IndexManagementPlugin bool `json:"indexManagementPlugin,omitempty"`
AlertingPlugin bool `json:"alertingPlugin,omitempty"`
BundledUseOnly bool `json:"bundledUseOnly,omitempty"`
UserRefs []*Reference `json:"userRefs,omitempty"`
UserRefs References `json:"userRefs,omitempty"`
//+kubuilder:validation:MaxItems:=1
ResizeSettings []*ResizeSettings `json:"resizeSettings,omitempty"`
//+kubuilder:validation:MaxItems:=1
Expand Down Expand Up @@ -531,7 +531,8 @@ type OpenSearchRestoreFrom struct {

// OpenSearchStatus defines the observed state of OpenSearch
type OpenSearchStatus struct {
ClusterStatus `json:",inline"`
ClusterStatus `json:",inline"`
AvailableUsers References `json:"availableUsers,omitempty"`
}

//+kubebuilder:object:root=true
Expand Down Expand Up @@ -607,6 +608,30 @@ func (oss *OpenSearchSpec) validateResizeSettings(nodesNumber int) error {
return nil
}

func (oss *OpenSearch) GetUserRefs() References {
return oss.Spec.UserRefs
}

func (oss *OpenSearch) SetUserRefs(refs References) {
oss.Spec.UserRefs = refs
}

func (oss *OpenSearch) GetAvailableUsers() References {
return oss.Status.AvailableUsers
}

func (oss *OpenSearch) SetAvailableUsers(users References) {
oss.Status.AvailableUsers = users
}

func (oss *OpenSearch) GetClusterID() string {
return oss.Status.ID
}

func (oss *OpenSearch) SetClusterID(id string) {
oss.Status.ID = id
}

func init() {
SchemeBuilder.Register(&OpenSearch{}, &OpenSearchList{})
}
31 changes: 28 additions & 3 deletions apis/clusters/v1beta1/redis_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,15 @@ type RedisSpec struct {
//+kubebuilder:validation:MaxItems:=2
DataCentres []*RedisDataCentre `json:"dataCentres,omitempty"`

UserRefs []*Reference `json:"userRefs,omitempty"`
UserRefs References `json:"userRefs,omitempty"`
//+kubebuilder:validation:MaxItems:=1
ResizeSettings []*ResizeSettings `json:"resizeSettings,omitempty"`
}

// RedisStatus defines the observed state of Redis
type RedisStatus struct {
ClusterStatus `json:",inline"`
ClusterStatus `json:",inline"`
AvailableUsers References `json:"availableUsers,omitempty"`
}

//+kubebuilder:object:root=true
Expand Down Expand Up @@ -297,7 +298,7 @@ func (rs *RedisSpec) DCsFromInstAPI(iDCs []*models.RedisDataCentre) (dcs []*Redi

func (rs *RedisStatus) FromInstAPI(iRedis *models.RedisCluster) RedisStatus {
return RedisStatus{
ClusterStatus{
ClusterStatus: ClusterStatus{
ID: iRedis.ID,
State: iRedis.Status,
DataCentres: rs.DCsFromInstAPI(iRedis.DataCentres),
Expand Down Expand Up @@ -464,6 +465,30 @@ func (rs *RedisSpec) ValidatePrivateLink() error {
return nil
}

func (r *Redis) GetUserRefs() References {
return r.Spec.UserRefs
}

func (r *Redis) SetUserRefs(refs References) {
r.Spec.UserRefs = refs
}

func (r *Redis) GetAvailableUsers() References {
return r.Status.AvailableUsers
}

func (r *Redis) SetAvailableUsers(users References) {
r.Status.AvailableUsers = users
}

func (r *Redis) GetClusterID() string {
return r.Status.ID
}

func (r *Redis) SetClusterID(id string) {
r.Status.ID = id
}

func init() {
SchemeBuilder.Register(&Redis{}, &RedisList{})
}
26 changes: 24 additions & 2 deletions apis/clusters/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions config/crd/bases/clusters.instaclustr.com_opensearches.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,18 @@ spec:
status:
description: OpenSearchStatus defines the observed state of OpenSearch
properties:
availableUsers:
items:
properties:
name:
type: string
namespace:
type: string
required:
- name
- namespace
type: object
type: array
cdcid:
type: string
currentClusterOperationStatus:
Expand Down
12 changes: 12 additions & 0 deletions config/crd/bases/clusters.instaclustr.com_redis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,18 @@ spec:
status:
description: RedisStatus defines the observed state of Redis
properties:
availableUsers:
items:
properties:
name:
type: string
namespace:
type: string
required:
- name
- namespace
type: object
type: array
cdcid:
type: string
currentClusterOperationStatus:
Expand Down
10 changes: 5 additions & 5 deletions config/samples/clusters_v1beta1_opensearch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,18 @@ spec:
# namespace: "default"
clusterManagerNodes:
- dedicatedManager: false
nodeSize: SRH-DEV-t4g.small-30
nodeSize: SRH-DEV-t4g.small-5
dataCentres:
- cloudProvider: AWS_VPC
name: AWS_VPC_US_EAST_1
network: 10.0.0.0/16
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
# 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
Expand Down
12 changes: 6 additions & 6 deletions config/samples/clusters_v1beta1_redis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ spec:
passwordAndUserAuth: true
privateNetworkCluster: false
userRefs:
# - name: redisuser-sample-1
# namespace: default
# - name: redisuser-sample-2
# namespace: default
# - name: redisuser-sample-3
# namespace: default
- name: redisuser-sample-1
namespace: default
- name: redisuser-sample-2
namespace: default
- name: redisuser-sample-3
namespace: default
# twoFactorDelete:
# - email: "[email protected]"
dataCentres:
Expand Down
Loading

0 comments on commit a4fd7f4

Please sign in to comment.