From 9aaa5842d36e89c6cae74298ac1d5c470b27e6a5 Mon Sep 17 00:00:00 2001 From: CeerDecy <79098669+CeerDecy@users.noreply.github.com> Date: Wed, 23 Oct 2024 09:43:17 +0800 Subject: [PATCH] fix: add status as a condition for searching registercenter (#6455) * fix: add status as a condition for searching registercenter Signed-off-by: CeerDecy <1748788674@qq.com> * remove useless code Signed-off-by: CeerDecy <1748788674@qq.com> --------- Signed-off-by: CeerDecy <1748788674@qq.com> --- internal/tools/orchestrator/dbclient/addon_instance.go | 1 + .../scheduler/executor/plugins/k8s/instanceinfosync/pod.go | 4 ---- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/internal/tools/orchestrator/dbclient/addon_instance.go b/internal/tools/orchestrator/dbclient/addon_instance.go index 398da09237e..71afda4b437 100644 --- a/internal/tools/orchestrator/dbclient/addon_instance.go +++ b/internal/tools/orchestrator/dbclient/addon_instance.go @@ -119,6 +119,7 @@ func (db *DBClient) GetAddonInstanceByNameAndCluster(addonName, cluster string) if err := db.Where("addon_name = ?", addonName). Where("az = ?", cluster). Where("is_deleted = ?", apistructs.AddonNotDeleted). + Where("status = ?", apistructs.AddonAttached). First(&instance).Error; err != nil { if gorm.IsRecordNotFoundError(err) { return nil, nil diff --git a/internal/tools/orchestrator/scheduler/executor/plugins/k8s/instanceinfosync/pod.go b/internal/tools/orchestrator/scheduler/executor/plugins/k8s/instanceinfosync/pod.go index 404c9a11a05..53436ba43d6 100644 --- a/internal/tools/orchestrator/scheduler/executor/plugins/k8s/instanceinfosync/pod.go +++ b/internal/tools/orchestrator/scheduler/executor/plugins/k8s/instanceinfosync/pod.go @@ -453,7 +453,6 @@ func updatePodAndInstance(dbclient *instanceinfo.Client, podlist *corev1.PodList mainContainer := getMainContainerStatus(pod.Status.ContainerStatuses, container.Name) terminatedContainer := mainContainer.LastTerminationState.Terminated if terminatedContainer != nil { - logrus.Infof("get [prevContainerID] from terminatedContainer") if len(strings.Split(terminatedContainer.ContainerID, "://")) == 2 { runtimeAndId := strings.Split(terminatedContainer.ContainerID, "://") prevContainerID = runtimeAndId[1] @@ -476,7 +475,6 @@ func updatePodAndInstance(dbclient *instanceinfo.Client, podlist *corev1.PodList } currentContainer := mainContainer.State.Running if currentContainer != nil { - logrus.Infof("get [currentContainerID] from currentContainer") if len(strings.Split(mainContainer.ContainerID, "://")) == 2 { runtimeAndId := strings.Split(mainContainer.ContainerID, "://") currentContainerID = runtimeAndId[1] @@ -614,8 +612,6 @@ func updatePodAndInstance(dbclient *instanceinfo.Client, podlist *corev1.PodList } logrus.Infof("latest instance id %v , others cleared by [prevContainerID]", instances[0].ID) } - } else { - logrus.Infof("[prevContainerID] is empty, skip create or update") } if currentContainerID != "" { instances, err := r.ByContainerID(currentContainerID).ByRuntimeID(runtimeID).ByApplicationID(applicationID).Do()