Skip to content

Commit

Permalink
fix(v2alpha2): fix endpoint have wrong pod
Browse files Browse the repository at this point in the history
  • Loading branch information
Rory-Z committed Jul 20, 2023
1 parent 7890524 commit c588285
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions controllers/apps/v2alpha2/add_svc.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,14 @@ func (a *addSvc) getPodList(ctx context.Context, instance *appsv2alpha2.EMQX) []

list := []corev1.Pod{}
for _, pod := range podList.Items {
if pod.Status.PodIP != "" {
list = append(list, pod)
for _, condition := range pod.Status.Conditions {
// We also add readiness gate to the pod, so if pod is ready, the EMQX will definitely be in the cluster.
// More info: https://git.k8s.io/enhancements/keps/sig-network/580-pod-readiness-gates
if condition.Type == corev1.PodReady && condition.Status == corev1.ConditionTrue {
if pod.Status.PodIP != "" {
list = append(list, pod)
}
}
}
}
return list
Expand Down

0 comments on commit c588285

Please sign in to comment.