mirror of
https://github.com/kubernetes-sigs/descheduler.git
synced 2026-01-26 05:14:13 +01:00
Merge pull request #336 from lixiang233/avoid_duplicated_append_RemoveDuplicatePods
avoid appending list multiple times in RemoveDuplicates
This commit is contained in:
@@ -86,11 +86,15 @@ func RemoveDuplicatePods(
|
|||||||
|
|
||||||
// If there have been any other pods with the same first "key", look through all the lists to see if any match
|
// If there have been any other pods with the same first "key", look through all the lists to see if any match
|
||||||
if existing, ok := duplicateKeysMap[podContainerKeys[0]]; ok {
|
if existing, ok := duplicateKeysMap[podContainerKeys[0]]; ok {
|
||||||
|
matched := false
|
||||||
for _, keys := range existing {
|
for _, keys := range existing {
|
||||||
if reflect.DeepEqual(keys, podContainerKeys) {
|
if reflect.DeepEqual(keys, podContainerKeys) {
|
||||||
|
matched = true
|
||||||
duplicatePods = append(duplicatePods, pod)
|
duplicatePods = append(duplicatePods, pod)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if !matched {
|
||||||
// Found no matches, add this list of keys to the list of lists that have the same first key
|
// Found no matches, add this list of keys to the list of lists that have the same first key
|
||||||
duplicateKeysMap[podContainerKeys[0]] = append(duplicateKeysMap[podContainerKeys[0]], podContainerKeys)
|
duplicateKeysMap[podContainerKeys[0]] = append(duplicateKeysMap[podContainerKeys[0]], podContainerKeys)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user