Skip to content

Commit c9779a9

Browse files
author
Jeff McCormick
committed
fix bug where backrest backup jobs were showing up in the pgo test pod list which causes an error in the output of pgo test
1 parent ac23dbe commit c9779a9

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

apiserver/clusterservice/clusterimpl.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,8 @@ func GetPods(cluster *crv1.Pgcluster) ([]msgs.ShowClusterPod, error) {
184184

185185
output := make([]msgs.ShowClusterPod, 0)
186186

187-
selector := util.LABEL_PGPOOL + "!=true," + util.LABEL_PG_CLUSTER + "=" + cluster.Spec.Name
187+
//get pods, but exclude pgpool and backup pods
188+
selector := util.LABEL_PGBACKUP + "!=true," + util.LABEL_PGBACKUP + "!=false," + util.LABEL_PGPOOL + "!=true," + util.LABEL_PG_CLUSTER + "=" + cluster.Spec.Name
188189

189190
pods, err := kubeapi.GetPods(apiserver.Clientset, selector, apiserver.Namespace)
190191
if err != nil {
@@ -336,7 +337,10 @@ func TestCluster(name, selector string) msgs.ClusterTestResponse {
336337
}
337338
item.PsqlString = "psql -p " + c.Spec.Port + " -h " + service.ClusterIP + " -U " + username + " " + database
338339
log.Debug(item.PsqlString)
339-
if service.Name != c.ObjectMeta.Name && replicaReady == false {
340+
log.Debug("jeff service.Name=" + service.Name)
341+
log.Debug("jeff c.ObjectMeta.Name=" + c.ObjectMeta.Name)
342+
log.Debugf("jeff replicaReady=%t", replicaReady)
343+
if (service.Name != c.ObjectMeta.Name) && replicaReady == false {
340344
item.Working = false
341345
} else {
342346
status := query(username, service.ClusterIP, c.Spec.Port, database, password)
@@ -358,7 +362,10 @@ func query(dbUser, dbHost, dbPort, database, dbPassword string) bool {
358362
var conn *sql.DB
359363
var err error
360364

361-
conn, err = sql.Open("postgres", "sslmode=disable user="+dbUser+" host="+dbHost+" port="+dbPort+" dbname="+database+" password="+dbPassword)
365+
connString := "sslmode=disable user=" + dbUser + " host=" + dbHost + " port=" + dbPort + " dbname=" + database + " password=" + dbPassword
366+
log.Debug("connString=" + connString)
367+
368+
conn, err = sql.Open("postgres", connString)
362369
if err != nil {
363370
log.Debug(err.Error())
364371
return false

conf/postgres-operator/backrest-job.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"labels": {
77
"vendor": "crunchydata",
88
"pgo-backrest": "true",
9+
"pgbackup": "true",
910
"pg-cluster": "{{.ClusterName}}"
1011
}
1112
},
@@ -16,6 +17,7 @@
1617
"labels": {
1718
"vendor": "crunchydata",
1819
"pgo-backrest": "true",
20+
"pgbackup": "true",
1921
"pg-cluster": "{{.ClusterName}}"
2022
}
2123
},

golang-examples/lag.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ func main() {
109109
fmt.Println(err.Error())
110110
os.Exit(2)
111111
}
112-
if len(deployments.Items) > 1 {
112+
if len(deployments.Items) < 1 {
113113
fmt.Println("no replica deployments found for " + clusterName)
114114
os.Exit(2)
115115
}
@@ -123,19 +123,20 @@ func main() {
123123

124124
for _, dep := range deployments.Items {
125125
//get the pods for each deployment
126+
fmt.Println("got deployment " + dep.Name)
126127
selector = "primary=false,replica-name=" + dep.Name
127128
podList, err := kubeapi.GetPods(kubeClient, selector, namespace)
128129
if err != nil {
129130
fmt.Println(err.Error())
130131
os.Exit(2)
131132
}
132-
if len(podList.Items) > 0 {
133-
selectedReplica = podList.Items[0]
133+
134+
//assume each deployment only has a single pod
135+
if len(podList.Items) == 1 {
134136
} else {
135137
fmt.Println("no replicas found")
136138
os.Exit(2)
137139
}
138-
139140
pod := podList.Items[0]
140141

141142
fmt.Println(pod.Name)

0 commit comments

Comments
 (0)