Skip to content

Commit

Permalink
Remove arbiter api when no arbiter node present
Browse files Browse the repository at this point in the history
Signed-off-by: souravbiswassanto <[email protected]>
  • Loading branch information
souravbiswassanto committed Nov 12, 2024
1 parent a8c8c1e commit 3cd0fd6
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions apis/kubedb/v1/postgres_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package v1

import (
"fmt"
"k8s.io/apimachinery/pkg/api/equality"
"strconv"
"time"

Expand Down Expand Up @@ -306,12 +307,16 @@ func (p *Postgres) SetDefaultReplicationMode(postgresVersion *catalog.PostgresVe
}

func (p *Postgres) SetArbiterDefault() {
if p.Spec.Arbiter == nil {
if ptr.Deref(p.Spec.Replicas, 0)%2 != 0 && p.Spec.Arbiter != nil {
if p.Spec.Arbiter.NodeSelector == nil && p.Spec.Arbiter.Tolerations == nil && equality.Semantic.DeepEqual(p.Spec.Arbiter.Resources, kubedb.DefaultArbiter(false)) {
p.Spec.Arbiter = nil
}
} else if ptr.Deref(p.Spec.Replicas, 0) != 0 && ptr.Deref(p.Spec.Replicas, 0)%2 == 0 && p.Spec.Arbiter == nil {
p.Spec.Arbiter = &ArbiterSpec{
Resources: core.ResourceRequirements{},
}
apis.SetDefaultResourceLimits(&p.Spec.Arbiter.Resources, kubedb.DefaultArbiter(false))
}
apis.SetDefaultResourceLimits(&p.Spec.Arbiter.Resources, kubedb.DefaultArbiter(false))
}

func (p *Postgres) setDefaultPodSecurityContext(podTemplate *ofstv2.PodTemplateSpec, pgVersion *catalog.PostgresVersion) {
Expand Down

0 comments on commit 3cd0fd6

Please sign in to comment.