This is an automated email from the ASF dual-hosted git repository.

caigy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/rocketmq-operator.git


The following commit(s) were added to refs/heads/master by this push:
     new d5e797b  Pod ready status reflect to cr (#186)
d5e797b is described below

commit d5e797b10d9c3e9275da715486b302365b7681ff
Author: yangw <wuyang...@gmail.com>
AuthorDate: Fri Dec 22 16:36:53 2023 +0800

    Pod ready status reflect to cr (#186)
---
 pkg/controller/broker/broker_controller.go | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/pkg/controller/broker/broker_controller.go 
b/pkg/controller/broker/broker_controller.go
index 030a3d6..86d2b8a 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)

Reply via email to