Skip to content

Commit

Permalink
perf: app ui last start (#259)
Browse files Browse the repository at this point in the history
Signed-off-by: 张启航 <101104760 [email protected]>
  • Loading branch information
ZhangSetSail authored Nov 1, 2024
1 parent a76c35f commit eb137cd
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions controllers/handler/app-ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 5,7 @@ import (
"fmt"
"os"
"strconv"
"time"

rainbondv1alpha1 "github.com/goodrain/rainbond-operator/api/v1alpha1"
checksqllite "github.com/goodrain/rainbond-operator/util/check-sqllite"
Expand Down Expand Up @@ -81,6 82,35 @@ func (a *appui) Resources() []client.Object {
}
var res []client.Object

// 定义标签选择器,筛选出 name=rbd-gateway 的 Pod
labelSelector := client.MatchingLabels{"name": "rbd-gateway"}
// 定义 Pod 列表对象,用于存储查询结果
var podList corev1.PodList

// 查询符合标签和命名空间的 Pod 列表
listOptions := []client.ListOption{
client.InNamespace(a.component.Namespace), // 指定命名空间
labelSelector, // 指定标签
}
for {
time.Sleep(5 * time.Second)
if err := a.client.List(a.ctx, &podList, listOptions...); err != nil {
log.Error(err, "list client failure")
continue
}

// 检查 Pod 是否已启动
AllRun := true
for _, pod := range podList.Items {
if pod.Status.Phase != corev1.PodRunning {
AllRun = false
}
}
if AllRun {
break
}
}

res = append(res, a.deploymentForAppUI())
res = append(res, a.serviceForAppUI(int32(p)))
res = append(res, rbdDefaultRouteForHTTP())
Expand Down

0 comments on commit eb137cd

Please sign in to comment.