Skip to content

Commit 85df5f3

Browse files
author
jmccormick2001
committed
fix pgbouncer and pgo test combination
1 parent 50f129a commit 85df5f3

File tree

3 files changed

+48
-21
lines changed

3 files changed

+48
-21
lines changed

apiserver/clusterservice/clusterimpl.go

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,10 @@ func getServices(cluster *crv1.Pgcluster) ([]msgs.ShowClusterService, error) {
252252
for _, p := range services.Items {
253253
d := msgs.ShowClusterService{}
254254
d.Name = p.Name
255+
if strings.Contains(p.Name, "-pgbouncer") {
256+
d.Pgbouncer = true
257+
d.ClusterName = cluster.Name
258+
}
255259
d.ClusterIP = p.Spec.ClusterIP
256260
if len(p.Spec.ExternalIPs) > 0 {
257261
d.ExternalIP = p.Spec.ExternalIPs[0]
@@ -352,26 +356,33 @@ func TestCluster(name, selector string) msgs.ClusterTestResponse {
352356
//for each service run a test and add results to output
353357
for _, service := range detail.Services {
354358

359+
databases := make([]string, 0)
360+
if service.Pgbouncer {
361+
databases = append(databases, service.ClusterName)
362+
databases = append(databases, service.ClusterName+"-replica")
363+
} else {
364+
databases = append(databases, "postgres")
365+
databases = append(databases, c.Spec.Database)
366+
}
355367
for _, s := range secrets {
356-
item := msgs.ClusterTestDetail{}
357-
username := s.Username
358-
password := s.Password
359-
database := "postgres"
360-
if username == c.Spec.User {
361-
database = c.Spec.Database
362-
}
363-
item.PsqlString = "psql -p " + c.Spec.Port + " -h " + service.ClusterIP + " -U " + username + " " + database
364-
log.Debug(item.PsqlString)
365-
if (service.Name != c.ObjectMeta.Name) && replicaReady == false {
366-
item.Working = false
367-
} else {
368-
status := query(username, service.ClusterIP, c.Spec.Port, database, password)
369-
item.Working = false
370-
if status {
371-
item.Working = true
368+
for _, db := range databases {
369+
item := msgs.ClusterTestDetail{}
370+
username := s.Username
371+
password := s.Password
372+
database := db
373+
item.PsqlString = "psql -p " + c.Spec.Port + " -h " + service.ClusterIP + " -U " + username + " " + database
374+
log.Debug(item.PsqlString)
375+
if (service.Name != c.ObjectMeta.Name) && replicaReady == false {
376+
item.Working = false
377+
} else {
378+
status := query(username, service.ClusterIP, c.Spec.Port, database, password)
379+
item.Working = false
380+
if status {
381+
item.Working = true
382+
}
372383
}
384+
result.Items = append(result.Items, item)
373385
}
374-
result.Items = append(result.Items, item)
375386
}
376387
}
377388
response.Results = append(response.Results, result)

apiservermsgs/clustermsgs.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,12 @@ type CreateClusterResponse struct {
5757

5858
// ShowClusterService
5959
type ShowClusterService struct {
60-
Name string
61-
Data string
62-
ClusterIP string
63-
ExternalIP string
60+
Name string
61+
Data string
62+
ClusterIP string
63+
ExternalIP string
64+
ClusterName string
65+
Pgbouncer bool
6466
}
6567

6668
const PodTypePrimary = "primary"

hugo/content/getting-started/_index.adoc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1338,6 +1338,20 @@ To update expired passwords in a cluster:
13381338
pgo user --update-passwords --selector=name=mycluster --expired=5
13391339
....
13401340
1341+
== pgbouncer Basics
1342+
1343+
Adding a pgbouncer deployment into your PG cluster follows
1344+
a sequence similar to this:
1345+
1346+
....
1347+
pgo create cluster mycluster --pgbouncer
1348+
....
1349+
1350+
You can also add pgbouncer after a cluster has been created:
1351+
....
1352+
pgo create pgbouncer mycluster
1353+
....
1354+
13411355
== pgpool Basics
13421356
13431357
Adding a pgpool deployment into your PG cluster follows

0 commit comments

Comments
 (0)