Skip to content

Commit

Permalink
chore: pick container ready pods
Browse files Browse the repository at this point in the history
Signed-off-by: Rory Z <[email protected]>
  • Loading branch information
Rory-Z committed Apr 9, 2024
1 parent 309d164 commit aa1ed99
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions controllers/apps/v2beta1/emqx_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ func (r *EMQXReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.

for _, subReconciler := range []subReconciler{
&addBootstrap{r},
&updatePodConditions{r},
&updateStatus{r},
&syncConfig{r},
&addCore{r},
Expand Down Expand Up @@ -198,13 +199,17 @@ func newRequester(ctx context.Context, k8sClient client.Client, instance *appsv2
})

for _, pod := range podList.Items {
if pod.GetDeletionTimestamp() == nil && pod.Status.Phase == corev1.PodRunning && pod.Status.PodIP != "" {
return &innerReq.Requester{
Schema: schema,
Host: net.JoinHostPort(pod.Status.PodIP, port),
Username: username,
Password: password,
}, nil
if pod.GetDeletionTimestamp() == nil && pod.Status.PodIP != "" {
for _, cond := range pod.Status.Conditions {
if cond.Type == corev1.ContainersReady && cond.Status == corev1.ConditionTrue {
return &innerReq.Requester{
Schema: schema,
Host: net.JoinHostPort(pod.Status.PodIP, port),
Username: username,
Password: password,
}, nil
}
}
}
}

Expand Down

0 comments on commit aa1ed99

Please sign in to comment.