Skip to content

Commit

Permalink
Merge pull request #606 from zhouhaoA1/feature_sort_nodes
Browse files Browse the repository at this point in the history
sort globalnode list by name when assign nodes in virutalcluster
  • Loading branch information
duanmengkk committed May 31, 2024
2 parents 786c3be + 880787f commit 3765be6
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/kubenest/controller/virtualcluster_init_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"encoding/base64"
"fmt"
"sort"
"sync"
"time"

Expand Down Expand Up @@ -285,6 +286,9 @@ func (c *VirtualClusterInitController) assignWorkNodes(virtualCluster *v1alpha1.
}
allNodeInfos := make([]v1alpha1.NodeInfo, 0)
globalNodes := globalNodeList.Items
sort.Slice(globalNodes, func(i, j int) bool {
return globalNodes[i].Name < globalNodes[j].Name
})
for _, policy := range virtualCluster.Spec.PromotePolicies {
nodeInfos, err := c.assignNodesByPolicy(virtualCluster, policy, globalNodes)
if err != nil {
Expand Down

0 comments on commit 3765be6

Please sign in to comment.