Skip to content

Commit

Permalink
Merge pull request #195 from k8s-proxmox/fix/node-score-plugin
Browse files Browse the repository at this point in the history
fix empty node score list error
  • Loading branch information
sp-yduck authored Feb 1, 2025
2 parents a98cc8d + 067b01c commit c9c9e66
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cloud/scheduler/plugins/noderesource/node_resrouce.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ func (pl *NodeResource) Score(ctx context.Context, state *framework.CycleState,
u := cpu / float32(maxCPU) * float32(mem/maxMem)
score := int64(1 / u)
status := framework.NewStatus()
status.SetCode(1)
status.SetCode(0)
return score, status
}
6 changes: 6 additions & 0 deletions cloud/scheduler/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -379,15 +379,21 @@ func (s *Scheduler) RunScorePlugins(ctx context.Context, state *framework.CycleS
s.logger.Info("scoring proxmox node")
status := framework.NewStatus()
scoresMap := make(map[string](map[int]framework.NodeScore))
for _, pl := range s.registry.ScorePlugins() {
scoresMap[pl.Name()] = make(map[int]framework.NodeScore)
}
nodeInfos, err := framework.GetNodeInfoList(ctx, s.client)
if err != nil {
status.SetCode(1)
s.logger.Error(err, "failed to get node info list")
return nil, status
}
for index, nodeInfo := range nodeInfos {
for _, pl := range s.registry.ScorePlugins() {
score, status := pl.Score(ctx, state, config, nodeInfo)
if !status.IsSuccess() {
status.SetCode(1)
s.logger.Error(status.Error(), fmt.Sprintf("failed to score node %s", nodeInfo.Node().Node))
return nil, status
}
scoresMap[pl.Name()][index] = framework.NodeScore{
Expand Down

0 comments on commit c9c9e66

Please sign in to comment.