Skip to content

Commit

Permalink
sort globalnode list by name when assign nodes in virutalcluster
Browse files Browse the repository at this point in the history
Signed-off-by: zhouhao_yewu <[email protected]>
  • Loading branch information
zhouhaoA1 committed May 31, 2024
1 parent 09edb14 commit 9ac0df5
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 9ac0df5

Please sign in to comment.