add comments

This commit is contained in:
Sergey Dudoladov
2020-04-07 09:29:52 +02:00
parent 8811dfd278
commit af30a55efa
2 changed files with 15 additions and 6 deletions
+10 -2
View File
@@ -296,10 +296,18 @@ func (c *Cluster) recreatePod(podName spec.NamespacedName) (*v1.Pod, error) {
func (c *Cluster) isSafeToRecreatePods(pods *v1.PodList) bool {
/*
Operator should not re-create pods if there is at least one replica being bootstrapped
because Patroni might use other replicas to take basebackup from (see Patroni's "clonefrom" tag).
XXX operator cannot forbid replica re-init, so we might still fail if re-init is started
after this check succeeds but before a pod is re-created
*/
for _, pod := range pods.Items {
state, err := c.patroni.GetNodeState(&pod)
if err != nil || state != "running" {
c.logger.Warningf("cannot re-create pod %s: patroni not in 'running' state", pod.Name)
c.logger.Warningf("cannot re-create pod %s: patroni in %s state", pod.Name, state)
return false
}
@@ -323,7 +331,7 @@ func (c *Cluster) recreatePods() error {
c.logger.Infof("there are %d pods in the cluster to recreate", len(pods.Items))
if !c.isSafeToRecreatePods(pods) {
return fmt.Errorf("postpone pod recreation until next Sync: some pods are being initilalized and recreation is unsafe")
return fmt.Errorf("postpone pod recreation until next Sync: recreation is unsafe because pods are being initilalized")
}
var (