Perform manual failover during the scale down

This commit is contained in:
Murat Kabilov
2017-10-16 17:41:23 +02:00
committed by GitHub
parent 5b29576a8e
commit 6c4cb4e9da
7 changed files with 121 additions and 13 deletions
+22 -2
View File
@@ -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()