Skip to content

Commit

Permalink
fix: add status as a condition for searching registercenter (erda-pro…
Browse files Browse the repository at this point in the history
…ject#6455)

* fix: add status as a condition for searching registercenter

Signed-off-by: CeerDecy <[email protected]>

* remove useless code

Signed-off-by: CeerDecy <[email protected]>

---------

Signed-off-by: CeerDecy <[email protected]>
  • Loading branch information
CeerDecy authored Oct 23, 2024
1 parent 7cd710a commit 9aaa584
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 4 deletions.
1 change: 1 addition & 0 deletions internal/tools/orchestrator/dbclient/addon_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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]
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 9aaa584

Please sign in to comment.