@@ -29,7 +29,9 @@ import (
29
29
networkingv1 "k8s.io/api/networking/v1"
30
30
apierrors "k8s.io/apimachinery/pkg/api/errors"
31
31
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
32
+ "k8s.io/apimachinery/pkg/labels"
32
33
"k8s.io/apimachinery/pkg/runtime"
34
+ "k8s.io/apimachinery/pkg/selection"
33
35
"k8s.io/apimachinery/pkg/types"
34
36
"k8s.io/apimachinery/pkg/util/intstr"
35
37
ctrl "sigs.k8s.io/controller-runtime"
@@ -696,18 +698,27 @@ func (r *PostgresReconciler) updatePatroniConfig(ctx context.Context, instance *
696
698
697
699
r .Log .Info ("Sending REST call to Patroni API" )
698
700
pods := & corev1.PodList {}
701
+
702
+ roleReq , err := labels .NewRequirement ("spilo-role" , selection .In , []string {"master" , "standby_leader" })
703
+ if err != nil {
704
+ r .Log .Info ("could not create requirements for label selector to query pods, requeuing" )
705
+ return err
706
+ }
707
+ leaderSelector := labels .NewSelector ()
708
+ leaderSelector = leaderSelector .Add (* roleReq )
709
+
699
710
opts := []client.ListOption {
700
711
client .InNamespace (instance .ToPeripheralResourceNamespace ()),
701
- client.MatchingLabels { "spilo-role" : "master" },
712
+ client.MatchingLabelsSelector { Selector : leaderSelector },
702
713
}
703
714
if err := r .SvcClient .List (ctx , pods , opts ... ); err != nil {
704
715
r .Log .Info ("could not query pods, requeuing" )
705
716
return err
706
717
}
707
718
if len (pods .Items ) == 0 {
708
- r .Log .Info ("no master pod ready, requeuing" )
719
+ r .Log .Info ("no leader pod ready, requeuing" )
709
720
// TODO return proper error
710
- return errors .New ("no master pods found" )
721
+ return errors .New ("no leader pods found" )
711
722
}
712
723
podIP := pods .Items [0 ].Status .PodIP
713
724
podPort := "8008"
0 commit comments