Skip to content

Commit

Permalink
Remove arbiter api when no arbiter node present (#1344)
Browse files Browse the repository at this point in the history
Signed-off-by: souravbiswassanto <saurov@appscode.com>
  • Loading branch information
souravbiswassanto authored Nov 15, 2024
1 parent 4ce2b88 commit 03df741
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions apis/kubedb/v1/postgres_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,12 +306,12 @@ 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 {
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
5 changes: 3 additions & 2 deletions apis/kubedb/v1alpha2/postgres_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
appslister "k8s.io/client-go/listers/apps/v1"
"k8s.io/utils/ptr"
kmapi "kmodules.xyz/client-go/api/v1"
"kmodules.xyz/client-go/apiextensions"
core_util "kmodules.xyz/client-go/core/v1"
Expand Down Expand Up @@ -315,12 +316,12 @@ 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 {
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) setDefaultInitContainerSecurityContext(podTemplate *ofst.PodTemplateSpec, pgVersion *catalog.PostgresVersion) {
Expand Down

0 comments on commit 03df741

Please sign in to comment.