Skip to content

Commit

Permalink
[CONTROLLER/RECORDER] fixes cleaning pod bug
Browse files Browse the repository at this point in the history
  • Loading branch information
zhengya authored and SongZhen0704 committed Jun 20, 2024
1 parent b15d959 commit 30df544
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
6 changes: 2 additions & 4 deletions server/controller/recorder/cache/tool/data_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -2080,14 +2080,12 @@ func (t *DataSet) GetVMIDByPodNodeID(podNodeID int) (int, bool) {
}
log.Warningf("cache %s id (%s id: %d) not found", ctrlrcommon.RESOURCE_TYPE_VM_EN, ctrlrcommon.RESOURCE_TYPE_POD_NODE_EN, podNodeID)
var conn mysql.VMPodNodeConnection
result := mysql.Db.Where("pod_node_id = ?", podNodeID).Find(&conn)
result := mysql.Db.Where("pod_node_id = ?", podNodeID).Find(&conn) // TODO is nessary to query MySQL?
if result.RowsAffected == 1 {
t.AddVMPodNodeConnection(&conn)
return conn.VMID, true
} else {
log.Errorf("db %s (%s id: %d) not found", ctrlrcommon.RESOURCE_TYPE_VM_POD_NODE_CONNECTION_EN, ctrlrcommon.RESOURCE_TYPE_POD_NODE_EN, podNodeID)
return 0, false
}
return 0, false
}

func (t *DataSet) GetPodNodeIDByVMPodNodeConnectionLcuuid(lcuuid string) (int, bool) {
Expand Down
2 changes: 1 addition & 1 deletion server/controller/recorder/cleaner.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ func (c *Cleaner) cleanPodNodeDirty() {
}

var pods []mysql.Pod
mysql.Db.Where("pod_node_id NOT IN ?", podNodeIDs).Find(&pods)
mysql.Db.Where("pod_node_id != 0 AND pod_node_id NOT IN ?", podNodeIDs).Find(&pods)
if len(pods) != 0 {
mysql.Db.Delete(&pods)
logErrorDeleteResourceTypeABecauseResourceTypeBHasGone(ctrlrcommon.RESOURCE_TYPE_POD_EN, ctrlrcommon.RESOURCE_TYPE_POD_NODE_EN, pods)
Expand Down

0 comments on commit 30df544

Please sign in to comment.