mirror of
https://github.com/zalando/postgres-operator.git
synced 2026-10-19 06:15:18 +02:00
Perform manual failover during the scale down
This commit is contained in:
+22
-2
@@ -11,12 +11,11 @@ import (
|
||||
)
|
||||
|
||||
func (c *Cluster) listPods() ([]v1.Pod, error) {
|
||||
ns := c.Namespace
|
||||
listOptions := metav1.ListOptions{
|
||||
LabelSelector: c.labelsSet().String(),
|
||||
}
|
||||
|
||||
pods, err := c.KubeClient.Pods(ns).List(listOptions)
|
||||
pods, err := c.KubeClient.Pods(c.Namespace).List(listOptions)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not get list of pods: %v", err)
|
||||
}
|
||||
@@ -24,6 +23,27 @@ func (c *Cluster) listPods() ([]v1.Pod, error) {
|
||||
return pods.Items, nil
|
||||
}
|
||||
|
||||
func (c *Cluster) getRolePods(role PostgresRole) ([]v1.Pod, error) {
|
||||
listOptions := metav1.ListOptions{
|
||||
LabelSelector: c.roleLabelsSet(role).String(),
|
||||
}
|
||||
|
||||
pods, err := c.KubeClient.Pods(c.Namespace).List(listOptions)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not get list of pods: %v", err)
|
||||
}
|
||||
|
||||
if len(pods.Items) == 0 {
|
||||
return nil, fmt.Errorf("no pods")
|
||||
}
|
||||
|
||||
if role == Master && len(pods.Items) > 1 {
|
||||
return nil, fmt.Errorf("too many masters")
|
||||
}
|
||||
|
||||
return pods.Items, nil
|
||||
}
|
||||
|
||||
func (c *Cluster) deletePods() error {
|
||||
c.logger.Debugln("deleting pods")
|
||||
pods, err := c.listPods()
|
||||
|
||||
Reference in New Issue
Block a user