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 3e0a37c
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions controllers/apps/v2beta1/emqx_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,13 +198,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 3e0a37c

Please sign in to comment.