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 aed1400 commit 25fd5b8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ jobs:
repository: ghcr.io/${{ github.repository }}
tag: ${{ github.ref_name }}
- name: Deploy emqx
timeout-minutes: 5
timeout-minutes: 10
uses: ./.github/actions/deploy-emqx
with:
kind: ${{ matrix.emqx[0] }}
Expand Down
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},
&addCore{r},
&addRepl{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 25fd5b8

Please sign in to comment.