func (r *ReconcileRethinkDBCluster) reconcileServerPods(cr *rethinkdbv1alpha1.RethinkDBCluster) error {
	servers, err := r.listServers(cr)
	if err != nil {
		log.Error(err, "unable to list servers")
		return err
	}
	serverCount := int32(len(servers))

	if serverCount < cr.Spec.Size {
		// Ensure all existing Pods are running before adding a new Pod.
		for _, pod := range servers {
			if pod.Status.Phase != corev1.PodRunning {
				log.Info("waiting for existing server pods to become ready...")
				return nil
			}
		}
		return r.addServer(cr, servers)
	} else if serverCount > cr.Spec.Size {
		return r.removeServer(cr, servers)
	}

	log.Info("correct cluster size reached", "size", serverCount)
	return nil
}
// reconcileServers ensures the requested number of server Pods are created.
reconcileServers ensures the requested number of server Pods are created.
// reconcileServers ensures the requested number of server Pods are created .
func (r *ReconcileRethinkDBCluster) reconcileServerPods(cr *rethinkdbv1alpha1.RethinkDBCluster) error {
	servers, err := r.listServers(cr)
	if err != nil {
		log.Error(err, "unable to list servers")
		return err
	}
	serverCount := int32(len(servers))
	if serverCount < cr.Spec.Size {
		for _, pod := range servers {
			if pod.Status.Phase != corev1.PodRunning {
				log.Info("waiting for existing server pods to become ready...")
				return nil
			}
		}
		return r.addServer(cr, servers)
	} else if serverCount > cr.Spec.Size {
		return r.removeServer(cr, servers)
	}
	log.Info("correct cluster size reached", "size", serverCount)
	return nil
}
func ( r * ReconcileRethinkDBCluster ) reconcileServerPods ( cr * rethinkdbv1alpha1 . RethinkDBCluster ) error { servers , err := r . listServers ( cr ) if err != nil { log . Error ( err , " " ) return err } serverCount := int32 ( len ( servers ) ) if serverCount < cr . Spec . Size { for _ , pod := range servers { if pod . Status . Phase != corev1 . PodRunning { log . Info ( " " ) return nil } } return r . addServer ( cr , servers ) } else if serverCount > cr . Spec . Size { return r . removeServer ( cr , servers ) } log . Info ( " " , " " , serverCount ) return nil }
reconcileServers ensures the requested number of server Pods are created.
reconcileServers ensures the requested number of server Pods are created .
// Ensure all existing Pods are running before adding a new Pod.