Skip to content

Commit

Permalink
Defaulting internal zookeper (#1398)
Browse files Browse the repository at this point in the history
Signed-off-by: pritamdas99 <pritam@appscode.com>
  • Loading branch information
pritamdas99 authored Feb 14, 2025
1 parent 2f6d49a commit 4713902
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 5 deletions.
4 changes: 2 additions & 2 deletions apis/kubedb/v1alpha2/openapi_generated.go

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

31 changes: 31 additions & 0 deletions apis/kubedb/v1alpha2/solr_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,34 @@ func (s Solr) CoordinatorSelectors() map[string]string {
return s.OffshootSelectors(map[string]string{string(SolrNodeRoleCoordinator): SolrNodeRoleSet})
}

func (s *Solr) SetDefaultsToZooKeeperRef() {
if s.Spec.ZookeeperRef == nil {
s.Spec.ZookeeperRef = &ZookeeperRef{}
}
s.SetZooKeeperObjectRef()
if s.Spec.ZookeeperRef.Version == nil {
defaultVersion := "3.7.2"
s.Spec.ZookeeperRef.Version = &defaultVersion
}
}

func (s *Solr) GetZooKeeperName() string {
return s.OffshootName() + "-zk"
}

func (s *Solr) SetZooKeeperObjectRef() {
if s.Spec.ZookeeperRef.ObjectReference == nil {
s.Spec.ZookeeperRef.ObjectReference = &kmapi.ObjectReference{}
}
if s.Spec.ZookeeperRef.Name == "" {
s.Spec.ZookeeperRef.ExternallyManaged = false
s.Spec.ZookeeperRef.Name = s.GetZooKeeperName()
}
if s.Spec.ZookeeperRef.Namespace == "" {
s.Spec.ZookeeperRef.Namespace = s.Namespace
}
}

func (s *Solr) SetDefaults() {
if s.Spec.DeletionPolicy == "" {
s.Spec.DeletionPolicy = DeletionPolicyDelete
Expand All @@ -285,6 +313,9 @@ func (s *Solr) SetDefaults() {
s.Spec.StorageType = StorageTypeDurable
}

s.SetDefaultsToZooKeeperRef()
s.SetZooKeeperObjectRef()

if s.Spec.ZookeeperDigestSecret == nil {
s.Spec.ZookeeperDigestSecret = &v1.LocalObjectReference{
Name: s.SolrSecretName("zk-digest"),
Expand Down
2 changes: 1 addition & 1 deletion apis/kubedb/v1alpha2/solr_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ type SolrSpec struct {
Storage *core.PersistentVolumeClaimSpec `json:"storage,omitempty"`

// // ZooKeeper contains information for Solr to store configurations for collections
ZookeeperRef *kmapi.ObjectReference `json:"zookeeperRef,omitempty"`
ZookeeperRef *ZookeeperRef `json:"zookeeperRef,omitempty"`

// +optional
SolrModules []string `json:"solrModules,omitempty"`
Expand Down
4 changes: 2 additions & 2 deletions apis/kubedb/v1alpha2/zz_generated.deepcopy.go

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

6 changes: 6 additions & 0 deletions crds/kubedb.com_solrs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13158,10 +13158,16 @@ spec:
x-kubernetes-map-type: atomic
zookeeperRef:
properties:
externallyManaged:
type: boolean
name:
type: string
namespace:
type: string
pathsBase:
type: string
version:
type: string
required:
- name
type: object
Expand Down

0 comments on commit 4713902

Please sign in to comment.