查询条件修改

This commit is contained in:
zhangwei 2023-11-29 19:16:36 +08:00
parent f09c82d7ab
commit eeaefa0eb6
2 changed files with 5 additions and 6 deletions

1
go.mod
View File

@ -2,7 +2,6 @@ module gitlink.org.cn/jcce-pcm/pcm-participant-kubernetes
go 1.21 go 1.21
toolchain go1.21.4
require ( require (
github.com/prometheus/client_golang v1.17.0 github.com/prometheus/client_golang v1.17.0

View File

@ -112,12 +112,12 @@ func apply(cloud *pcmCore.CloudInfo, svc *svc.ServiceContext) {
func DeploymentHandler(cloudInfo *pcmCore.CloudInfo, svc *svc.ServiceContext) { func DeploymentHandler(cloudInfo *pcmCore.CloudInfo, svc *svc.ServiceContext) {
// 遍历core端任务列表信息 // 遍历core端任务列表信息
deploymentList, err := svc.ClientSet.AppsV1().Deployments("").List(context.Background(), metav1.ListOptions{}) deploymentList, err := svc.ClientSet.AppsV1().Deployments(cloudInfo.Namespace).List(context.Background(), metav1.ListOptions{})
if err != nil { if err != nil {
return return
} }
for _, deployment := range deploymentList.Items { for _, deployment := range deploymentList.Items {
if deployment.Namespace == cloudInfo.Namespace && deployment.Name == cloudInfo.Name { if deployment.Name == cloudInfo.Name {
cloudInfo.StartTime = tool.TimeRemoveZone(deployment.Status.Conditions[0].LastTransitionTime.Time).String() cloudInfo.StartTime = tool.TimeRemoveZone(deployment.Status.Conditions[0].LastTransitionTime.Time).String()
// 判断状态 // 判断状态
if deployment.Status.Replicas == 0 && deployment.Status.ReadyReplicas != 0 { if deployment.Status.Replicas == 0 && deployment.Status.ReadyReplicas != 0 {
@ -133,13 +133,13 @@ func DeploymentHandler(cloudInfo *pcmCore.CloudInfo, svc *svc.ServiceContext) {
func StatefulSetHandler(cloudInfo *pcmCore.CloudInfo, svc *svc.ServiceContext) { func StatefulSetHandler(cloudInfo *pcmCore.CloudInfo, svc *svc.ServiceContext) {
// 遍历core端任务列表信息 // 遍历core端任务列表信息
stsList, err := svc.ClientSet.AppsV1().StatefulSets("").List(context.Background(), metav1.ListOptions{}) stsList, err := svc.ClientSet.AppsV1().StatefulSets(cloudInfo.Namespace).List(context.Background(), metav1.ListOptions{})
if err != nil { if err != nil {
return return
} }
for _, sts := range stsList.Items { for _, sts := range stsList.Items {
if sts.Namespace == cloudInfo.Namespace && sts.Name == cloudInfo.Name { if sts.Name == cloudInfo.Name {
cloudInfo.StartTime = tool.TimeRemoveZone(sts.Status.Conditions[0].LastTransitionTime.Time).String() cloudInfo.StartTime = tool.TimeRemoveZone(sts.CreationTimestamp.Time).String()
// 判断状态 // 判断状态
if sts.Status.Replicas == 0 && sts.Status.ReadyReplicas != 0 { if sts.Status.Replicas == 0 && sts.Status.ReadyReplicas != 0 {
cloudInfo.Status = "Updating" cloudInfo.Status = "Updating"