@@ -41,7 +41,6 @@ import (
4141 kerrors "k8s.io/apimachinery/pkg/api/errors"
4242 "k8s.io/apimachinery/pkg/api/resource"
4343 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
44- "k8s.io/apimachinery/pkg/fields"
4544 "k8s.io/apimachinery/pkg/util/validation"
4645 "k8s.io/client-go/kubernetes"
4746)
@@ -2320,16 +2319,10 @@ func GetPrimaryAndReplicaPods(cluster *crv1.Pgcluster, ns string) ([]msgs.ShowCl
23202319 ctx := context .TODO ()
23212320 output := make ([]msgs.ShowClusterPod , 0 )
23222321
2323- // find all of the Pods that represent Postgres primary and replicas.
2324- // only consider running Pods
23252322 selector := config .LABEL_SERVICE_NAME + "=" + cluster .Spec .Name + "," + config .LABEL_DEPLOYMENT_NAME
2323+ log .Debugf ("selector for GetPrimaryAndReplicaPods is %s" , selector )
23262324
2327- options := metav1.ListOptions {
2328- FieldSelector : fields .OneTermEqualSelector ("status.phase" , string (v1 .PodRunning )).String (),
2329- LabelSelector : selector ,
2330- }
2331-
2332- pods , err := apiserver .Clientset .CoreV1 ().Pods (ns ).List (ctx , options )
2325+ pods , err := apiserver .Clientset .CoreV1 ().Pods (ns ).List (ctx , metav1.ListOptions {LabelSelector : selector })
23332326 if err != nil {
23342327 return output , err
23352328 }
@@ -2350,12 +2343,9 @@ func GetPrimaryAndReplicaPods(cluster *crv1.Pgcluster, ns string) ([]msgs.ShowCl
23502343
23512344 }
23522345 selector = config .LABEL_SERVICE_NAME + "=" + cluster .Spec .Name + "-replica" + "," + config .LABEL_DEPLOYMENT_NAME
2353- options = metav1.ListOptions {
2354- FieldSelector : fields .OneTermEqualSelector ("status.phase" , string (v1 .PodRunning )).String (),
2355- LabelSelector : selector ,
2356- }
2346+ log .Debugf ("selector for GetPrimaryAndReplicaPods is %s" , selector )
23572347
2358- pods , err = apiserver .Clientset .CoreV1 ().Pods (ns ).List (ctx , options )
2348+ pods , err = apiserver .Clientset .CoreV1 ().Pods (ns ).List (ctx , metav1. ListOptions { LabelSelector : selector } )
23592349 if err != nil {
23602350 return output , err
23612351 }
0 commit comments