Skip to content

Commit

Permalink
fix deployer resource check bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Yiling-J committed Dec 27, 2024
1 parent 68836c4 commit 2547541
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 5 additions & 1 deletion builder/deploy/deployer.go
Original file line number Diff line number Diff line change
Expand Up @@ -728,7 +728,11 @@ func CheckResource(clusterResources *types.ClusterRes, hardware *types.HardWare)
}
for _, node := range clusterResources.Resources {
if float32(mem) <= node.AvailableMem {
return checkNodeResource(node, hardware)
isAvailable := checkNodeResource(node, hardware)
if isAvailable {
// if true return, otherwise continue check next node
return true
}
}
}
return false
Expand Down
5 changes: 5 additions & 0 deletions builder/deploy/deployer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -691,13 +691,18 @@ func TestDeployer_CheckResource(t *testing.T) {
Gpu: types.GPU{Num: "1", Type: "t1"},
Cpu: types.CPU{Num: "20"},
}, false},
{&types.HardWare{
Gpu: types.GPU{Num: "1", Type: "t1"},
Cpu: types.CPU{Num: "12"},
}, true},
}

for _, c := range cases {
c.hardware.Memory = "1Gi"
v := CheckResource(&types.ClusterRes{
Resources: []types.NodeResourceInfo{
{AvailableXPU: 10, XPUModel: "t1", AvailableCPU: 10, AvailableMem: 10000},
{AvailableXPU: 12, XPUModel: "t1", AvailableCPU: 12, AvailableMem: 10000},
},
}, c.hardware)
require.Equal(t, c.available, v, c.hardware)
Expand Down

0 comments on commit 2547541

Please sign in to comment.