Skip to content

Commit afae154

Browse files
author
jmccormick2001
committed
fix scenario: pgbackrest, restore, autofail turned back on, then trigger an autofail
1 parent f76baa7 commit afae154

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

controller/podcontroller.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -261,19 +261,19 @@ func isPostgresPod(newpod *apiv1.Pod) bool {
261261
return false
262262
}
263263
if newpod.ObjectMeta.Labels[util.LABEL_NAME] == "postgres-operator" {
264-
log.Debugf("postgres-operator-pod added [%s]", newpod.Name)
264+
log.Debugf("postgres-operator-pod found [%s]", newpod.Name)
265265
return false
266266
}
267267
if newpod.ObjectMeta.Labels[util.LABEL_PGO_BACKREST_REPO] == "true" {
268-
log.Debugf("pgo-backrest-repo pod added [%s]", newpod.Name)
268+
log.Debugf("pgo-backrest-repo pod found [%s]", newpod.Name)
269269
return false
270270
}
271271
if newpod.ObjectMeta.Labels[util.LABEL_PGPOOL] == "true" {
272-
log.Debugf("pgpool pod added [%s]", newpod.Name)
272+
log.Debugf("pgpool pod found [%s]", newpod.Name)
273273
return false
274274
}
275275
if newpod.ObjectMeta.Labels[util.LABEL_PGBOUNCER] == "true" {
276-
log.Debugf("pgbouncer pod added [%s]", newpod.Name)
276+
log.Debugf("pgbouncer pod found [%s]", newpod.Name)
277277
return false
278278
}
279279
return true

operator/cluster/failover_strategy_1.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ package cluster
2020

2121
import (
2222
"errors"
23-
log "github.com/sirupsen/logrus"
2423
crv1 "github.com/crunchydata/postgres-operator/apis/cr/v1"
2524
"github.com/crunchydata/postgres-operator/kubeapi"
2625
"github.com/crunchydata/postgres-operator/util"
26+
log "github.com/sirupsen/logrus"
2727
"k8s.io/api/core/v1"
2828
"k8s.io/api/extensions/v1beta1"
2929
"k8s.io/client-go/kubernetes"
@@ -149,8 +149,8 @@ func updateFailoverStatus(client *rest.RESTClient, task *crv1.Pgtask, namespace,
149149
func deletePrimary(clientset *kubernetes.Clientset, namespace, clusterName string) error {
150150

151151
//the primary will be the one with a pod that has a label
152-
//that looks like service-name=clustername
153-
selector := util.LABEL_SERVICE_NAME + "=" + clusterName
152+
//that looks like service-name=clustername and is not a backrest job
153+
selector := util.LABEL_SERVICE_NAME + "=" + clusterName + "," + util.LABEL_BACKREST_RESTORE + "!=true," + util.LABEL_BACKREST_JOB + "!=true"
154154
pods, err := kubeapi.GetPods(clientset, selector, namespace)
155155
if len(pods.Items) == 0 {
156156
log.Errorf("no primary pod found when trying to delete primary %s", selector)

0 commit comments

Comments
 (0)