Avoid passing the role into the recreatePod.

Conceptually, the operator's task is just to change the pod. As it
has no influence over the role the pod will take (either the master
or a replica), it shouldn't wait for the specific role.

This fixes at least one issue, where the pod running in a single-pod
cluster has been waited for forever by the operator expecting it to
have a wrong role (since Patroni callback assiging it the original
replica role has been killed after a quick promote by the next
callback.)
This commit is contained in:
Oleksii Kliukin
2017-05-12 11:41:32 +02:00
committed by Murat Kabilov
parent 8e658174e8
commit 176c6e8b19
3 changed files with 11 additions and 9 deletions
+4 -4
View File
@@ -112,7 +112,7 @@ func (c *Cluster) registerPodSubscriber(podName spec.PodName) chan spec.PodEvent
return ch
}
func (c *Cluster) recreatePod(pod v1.Pod, spiloRole string) error {
func (c *Cluster) recreatePod(pod v1.Pod) error {
podName := spec.PodName{
Namespace: pod.Namespace,
Name: pod.Name,
@@ -133,7 +133,7 @@ func (c *Cluster) recreatePod(pod v1.Pod, spiloRole string) error {
if err := c.waitForPodDeletion(ch); err != nil {
return err
}
if err := c.waitForPodLabel(ch, spiloRole); err != nil {
if err := c.waitForPodLabel(ch); err != nil {
return err
}
c.logger.Infof("Pod '%s' is ready", podName)
@@ -184,7 +184,7 @@ func (c *Cluster) recreatePods() error {
continue
}
err = c.recreatePod(pod, "replica")
err = c.recreatePod(pod)
if err != nil {
return fmt.Errorf("Can't recreate replica Pod '%s': %s", util.NameFromMeta(pod.ObjectMeta), err)
}
@@ -197,7 +197,7 @@ func (c *Cluster) recreatePods() error {
//TODO: specify master, leave new master empty
c.logger.Infof("Recreating master Pod '%s'", util.NameFromMeta(masterPod.ObjectMeta))
if err := c.recreatePod(masterPod, "replica"); err != nil {
if err := c.recreatePod(masterPod); err != nil {
return fmt.Errorf("Can't recreate master Pod '%s': %s", util.NameFromMeta(masterPod.ObjectMeta), err)
}