Skip to content

Commit

Permalink
SKS-2160: Fix 'where' condition when getting GPU device allocation de…
Browse files Browse the repository at this point in the history
…tails (#157)
  • Loading branch information
haijianyang authored Dec 1, 2023
1 parent 7740e82 commit 2fe52eb
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions pkg/service/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -970,21 +970,19 @@ func (svr *TowerVMService) GetGPUDevicesAllocationInfoByHostIDs(hostIDs []string
return NewGPUVMInfos(), nil
}

where := &models.GpuDeviceWhereInput{
UserUsage: models.NewGpuDeviceUsage(gpuDeviceUsage),
Host: &models.HostWhereInput{
IDIn: hostIDs,
getDetailVMInfoByGpuDevicesParams := clientgpu.NewGetDetailVMInfoByGpuDevicesParams()
getDetailVMInfoByGpuDevicesParams.RequestBody = &models.GetGpuDevicesRequestBody{
Where: &models.GpuDeviceWhereInput{
UserUsage: models.NewGpuDeviceUsage(gpuDeviceUsage),
Host: &models.HostWhereInput{
IDIn: hostIDs,
},
},
}

// Filter GPU devices whose vGPU has been fully used
if gpuDeviceUsage == models.GpuDeviceUsageVGPU {
where.AvailableVgpusNumGt = TowerInt32(0)
}

getDetailVMInfoByGpuDevicesParams := clientgpu.NewGetDetailVMInfoByGpuDevicesParams()
getDetailVMInfoByGpuDevicesParams.RequestBody = &models.GetGpuDevicesRequestBody{
Where: &models.GpuDeviceWhereInput{},
getDetailVMInfoByGpuDevicesParams.RequestBody.Where.AvailableVgpusNumGt = TowerInt32(0)
}

getDetailVMInfoByGpuDevicesResp, err := svr.Session.GpuDevice.GetDetailVMInfoByGpuDevices(getDetailVMInfoByGpuDevicesParams)
Expand Down

0 comments on commit 2fe52eb

Please sign in to comment.