Skip to content

Commit

Permalink
Merge pull request #264 from vshn/disableConnectionPooling
Browse files Browse the repository at this point in the history
Allow to disable PgBouncer in VSHNPostgreSQL
  • Loading branch information
zugao authored Nov 18, 2024
2 parents fc026b1 + dd1feba commit 5fe18eb
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 0 deletions.
5 changes: 5 additions & 0 deletions apis/vshn/v1/dbaas_vshn_postgresql.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package v1

import (
"fmt"

xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1"
sgv1 "github.com/vshn/appcat/v4/apis/stackgres/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -147,6 +148,10 @@ type VSHNPostgreSQLServiceSpec struct {
// PgBouncerSettings passes additional configuration to the pgBouncer instance.
PgBouncerSettings *sgv1.SGPoolingConfigSpecPgBouncerPgbouncerIni `json:"pgBouncerSettings,omitempty"`

// Disable connection pooling service PgBouncer. All connections will go straight to PostgreSQL instance.
// +kubebuilder:default=false
DisablePgBouncer bool `json:"DisablePgBouncer,omitempty"`

// +kubebuilder:default=true
// This is default option if neither repack or vacuum are selected
RepackEnabled bool `json:"repackEnabled,omitempty"`
Expand Down
4 changes: 4 additions & 0 deletions crds/vshn.appcat.vshn.io_vshnkeycloaks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9775,6 +9775,10 @@ spec:
service:
description: Service contains PostgreSQL DBaaS specific properties
properties:
DisablePgBouncer:
default: false
description: Disable connection pooling service PgBouncer. All connections will go straight to PostgreSQL instance.
type: boolean
access:
description: Access defines additional users and databases for this instance.
items:
Expand Down
7 changes: 7 additions & 0 deletions crds/vshn.appcat.vshn.io_vshnnextclouds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4852,11 +4852,14 @@ spec:
description: Service contains nextcloud DBaaS specific properties
properties:
collabora:
description: Collabora contains settings to control the Collabora integration.
properties:
enabled:
default: false
description: Enabled enables the Collabora integration. It will autoconfigure the Collabora server URL in Your Nextcloud instance.
type: boolean
fqdn:
description: FQDN contains the FQDN of the Collabora server. This is used to configure the Collabora server URL in Your Nextcloud instance.
type: string
required:
- enabled
Expand Down Expand Up @@ -9751,6 +9754,10 @@ spec:
service:
description: Service contains PostgreSQL DBaaS specific properties
properties:
DisablePgBouncer:
default: false
description: Disable connection pooling service PgBouncer. All connections will go straight to PostgreSQL instance.
type: boolean
access:
description: Access defines additional users and databases for this instance.
items:
Expand Down
4 changes: 4 additions & 0 deletions crds/vshn.appcat.vshn.io_vshnpostgresqls.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4965,6 +4965,10 @@ spec:
service:
description: Service contains PostgreSQL DBaaS specific properties
properties:
DisablePgBouncer:
default: false
description: Disable connection pooling service PgBouncer. All connections will go straight to PostgreSQL instance.
type: boolean
access:
description: Access defines additional users and databases for this instance.
items:
Expand Down
5 changes: 5 additions & 0 deletions crds/vshn.appcat.vshn.io_xvshnkeycloaks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11555,6 +11555,11 @@ spec:
description: Service contains PostgreSQL DBaaS specific
properties
properties:
DisablePgBouncer:
default: false
description: Disable connection pooling service PgBouncer.
All connections will go straight to PostgreSQL instance.
type: boolean
access:
description: Access defines additional users and databases
for this instance.
Expand Down
13 changes: 13 additions & 0 deletions crds/vshn.appcat.vshn.io_xvshnnextclouds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5576,11 +5576,19 @@ spec:
description: Service contains nextcloud DBaaS specific properties
properties:
collabora:
description: Collabora contains settings to control the Collabora
integration.
properties:
enabled:
default: false
description: Enabled enables the Collabora integration.
It will autoconfigure the Collabora server URL in Your
Nextcloud instance.
type: boolean
fqdn:
description: FQDN contains the FQDN of the Collabora server.
This is used to configure the Collabora server URL in
Your Nextcloud instance.
type: string
required:
- enabled
Expand Down Expand Up @@ -11529,6 +11537,11 @@ spec:
description: Service contains PostgreSQL DBaaS specific
properties
properties:
DisablePgBouncer:
default: false
description: Disable connection pooling service PgBouncer.
All connections will go straight to PostgreSQL instance.
type: boolean
access:
description: Access defines additional users and databases
for this instance.
Expand Down
5 changes: 5 additions & 0 deletions crds/vshn.appcat.vshn.io_xvshnpostgresqls.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5647,6 +5647,11 @@ spec:
service:
description: Service contains PostgreSQL DBaaS specific properties
properties:
DisablePgBouncer:
default: false
description: Disable connection pooling service PgBouncer.
All connections will go straight to PostgreSQL instance.
type: boolean
access:
description: Access defines additional users and databases
for this instance.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,7 @@ func createSgCluster(ctx context.Context, comp *vshnv1.VSHNPostgreSQL, svc *runt
Scheduling: &sgv1.SGClusterSpecPodsScheduling{
NodeSelector: nodeSelector,
},
DisableConnectionPooling: ptr.To(false),
},
NonProductionOptions: &sgv1.SGClusterSpecNonProductionOptions{
EnableSetPatroniCpuRequests: ptr.To(true),
Expand All @@ -437,6 +438,11 @@ func createSgCluster(ctx context.Context, comp *vshnv1.VSHNPostgreSQL, svc *runt
},
},
}

if !comp.Spec.Parameters.Service.DisablePgBouncer {
sgCluster.Spec.Pods.DisableConnectionPooling = ptr.To(true)
}

configureReplication(comp, sgCluster)

err = svc.SetDesiredKubeObjectWithName(sgCluster, comp.GetName()+"-cluster", "cluster", runtime.KubeOptionAddRefs(backupRef))
Expand Down

0 comments on commit 5fe18eb

Please sign in to comment.