diff --git a/pkg/controller/broker/broker_controller.go b/pkg/controller/broker/broker_controller.go index 030a3d65..86d2b8a1 100644 --- a/pkg/controller/broker/broker_controller.go +++ b/pkg/controller/broker/broker_controller.go @@ -267,11 +267,15 @@ func (r *ReconcileBroker) Reconcile(ctx context.Context, request reconcile.Reque podNames := getPodNames(podList.Items) log.Info("broker.Status.Nodes length = " + strconv.Itoa(len(broker.Status.Nodes))) log.Info("podNames length = " + strconv.Itoa(len(podNames))) - // Ensure every pod is in running phase + // Ensure every pod is in ready for _, pod := range podList.Items { if !reflect.DeepEqual(pod.Status.Phase, corev1.PodRunning) { log.Info("pod " + pod.Name + " phase is " + string(pod.Status.Phase) + ", wait for a moment...") } + if !isReady(pod) { + reqLogger.Info("pod " + pod.Name + " is not ready, wait for a moment...") + return reconcile.Result{Requeue: true, RequeueAfter: time.Duration(cons.RequeueIntervalInSecond) * time.Second}, nil + } } if broker.Status.Size != 0 && broker.Spec.Size > broker.Status.Size { @@ -398,6 +402,15 @@ func getBrokerName(broker *rocketmqv1alpha1.Broker, brokerGroupIndex int) string return broker.Name + "-" + strconv.Itoa(brokerGroupIndex) } +func isReady(po corev1.Pod) bool { + for _, cond := range po.Status.Conditions { + if cond.Type == corev1.PodReady { + return cond.Status == corev1.ConditionTrue + } + } + return false +} + // getBrokerStatefulSet returns a broker StatefulSet object func (r *ReconcileBroker) getBrokerStatefulSet(broker *rocketmqv1alpha1.Broker, brokerGroupIndex int, replicaIndex int) *appsv1.StatefulSet { ls := labelsForBroker(broker.Name)