Skip to content

Commit

Permalink
Add validator to check negative number of replicas. (#1124)
Browse files Browse the repository at this point in the history
Signed-off-by: pritamdas99 <pritam@appscode.com>
  • Loading branch information
pritamdas99 committed Jan 22, 2024
1 parent cc189c3 commit a28b266
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions apis/kubedb/v1alpha2/solr_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,11 @@ func (s *Solr) ValidateCreateOrUpdate() field.ErrorList {
}

if s.Spec.Topology == nil {
if s.Spec.Replicas != nil && *s.Spec.Replicas <= 0 {
allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("replicas"),
s.Name,
"number of replicas can not be less be 0 or less"))
}
err := solrValidateVolumes(&s.Spec.PodTemplate)
if err != nil {
allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("podTemplate").Child("spec").Child("volumes"),
Expand All @@ -176,11 +181,6 @@ func (s *Solr) ValidateCreateOrUpdate() field.ErrorList {
allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("topology").Child("data"),
s.Name,
".spec.topology.data can't be empty in cluster mode"))
if s.Spec.Replicas != nil && *s.Spec.Replicas <= 0 {
allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("replicas"),
s.Name,
"number of replicas can not be less be 0 or less"))
}
}
if s.Spec.Topology.Data.Replicas != nil && *s.Spec.Topology.Data.Replicas <= 0 {
allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("topology").Child("data").Child("replicas"),
Expand Down

0 comments on commit a28b266

Please sign in to comment.