Skip to content

Commit

Permalink
Fix SingleStore Default Resources Issue
Browse files Browse the repository at this point in the history
Signed-off-by: ashraful <[email protected]>
  • Loading branch information
AshrafulHaqueToni committed Feb 9, 2024
1 parent 992de06 commit 224b936
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 29 deletions.
7 changes: 0 additions & 7 deletions apis/kubedb/v1alpha2/openapi_generated.go

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

32 changes: 29 additions & 3 deletions apis/kubedb/v1alpha2/singlestore_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"fmt"
"strings"

"kubedb.dev/apimachinery/apis"
catalog "kubedb.dev/apimachinery/apis/catalog/v1alpha1"
"kubedb.dev/apimachinery/apis/kubedb"
"kubedb.dev/apimachinery/crds"
Expand Down Expand Up @@ -277,10 +278,16 @@ func (s *Singlestore) SetDefaults() {
s.setDefaultContainerSecurityContext(&sdbVersion, s.Spec.Topology.Leaf.PodTemplate)
}

if s.Spec.EnableSSL {
s.SetTLSDefaults()
}
s.SetTLSDefaults()

s.SetHealthCheckerDefaults()

if s.IsClustering() {
s.setDefaultContainerResourceLimits(s.Spec.Topology.Aggregator.PodTemplate)
s.setDefaultContainerResourceLimits(s.Spec.Topology.Leaf.PodTemplate)
} else {
s.setDefaultContainerResourceLimits(s.Spec.PodTemplate)
}
}

func (s *Singlestore) setDefaultContainerSecurityContext(sdbVersion *catalog.SinglestoreVersion, podTemplate *ofst.PodTemplateSpec) {
Expand Down Expand Up @@ -379,6 +386,25 @@ func (s *Singlestore) assignDefaultContainerSecurityContext(sdbVersion *catalog.
}
}

func (s *Singlestore) setDefaultContainerResourceLimits(podTemplate *ofst.PodTemplateSpec) {
dbContainer := coreutil.GetContainerByName(podTemplate.Spec.Containers, SinglestoreContainerName)
if dbContainer != nil && (dbContainer.Resources.Requests == nil || dbContainer.Resources.Limits == nil) {
apis.SetDefaultResourceLimits(&dbContainer.Resources, DefaultResources)
}

initContainer := coreutil.GetContainerByName(podTemplate.Spec.InitContainers, SinglestoreInitContainerName)
if initContainer != nil && (initContainer.Resources.Requests == nil || initContainer.Resources.Limits == nil) {
apis.SetDefaultResourceLimits(&initContainer.Resources, DefaultInitContainerResource)
}

if s.IsClustering() {
coordinatorContainer := coreutil.GetContainerByName(podTemplate.Spec.Containers, SinglestoreCoordinatorContainerName)
if coordinatorContainer != nil && (coordinatorContainer.Resources.Requests == nil || coordinatorContainer.Resources.Limits == nil) {
apis.SetDefaultResourceLimits(&coordinatorContainer.Resources, CoordinatorDefaultResources)
}
}
}

func (s *Singlestore) SetTLSDefaults() {
if s.Spec.TLS == nil || s.Spec.TLS.IssuerRef == nil {
return
Expand Down
3 changes: 0 additions & 3 deletions apis/kubedb/v1alpha2/singlestore_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,6 @@ type SinglestoreSpec struct {
// Storage to specify how storage shall be used.
Storage *core.PersistentVolumeClaimSpec `json:"storage,omitempty"`

// To enable ssl for http layer
EnableSSL bool `json:"enableSSL,omitempty"`

// Init is used to initialize database
// +optional
Init *InitSpec `json:"init,omitempty"`
Expand Down
14 changes: 0 additions & 14 deletions apis/kubedb/v1alpha2/singlestore_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,20 +97,6 @@ func (s *Singlestore) ValidateDelete() (admission.Warnings, error) {
func (s *Singlestore) ValidateCreateOrUpdate() field.ErrorList {
var allErr field.ErrorList

if s.Spec.EnableSSL {
if s.Spec.TLS == nil {
allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("enableSSL"),
s.Name,
".spec.tls can't be nil, if .spec.enableSSL is true"))
}
} else {
if s.Spec.TLS != nil {
allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("enableSSL"),
s.Name,
".spec.tls must be nil, if .spec.enableSSL is disabled"))
}
}

if s.Spec.Version == "" {
allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("version"),
s.Name,
Expand Down
2 changes: 0 additions & 2 deletions crds/kubedb.com_singlestores.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ spec:
type: string
type: object
x-kubernetes-map-type: atomic
enableSSL:
type: boolean
halted:
type: boolean
healthChecker:
Expand Down

0 comments on commit 224b936

Please sign in to comment.