Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions pkg/brgpu/kata.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,15 +201,10 @@ func vfDeviceDiscover() (PFDeviceInfoList, error) {
}

vfs = append(vfs, VFDeviceInfo{
DeviceID: deviceID,
IOMMUGroup: iommuGroup,
Addr: vfAddr,
ResourceName: func() string {
if vfNum == 1 {
return "gpu"
}
return fmt.Sprintf("1-%d-gpu", vfNum)
}(),
DeviceID: deviceID,
IOMMUGroup: iommuGroup,
Addr: vfAddr,
ResourceName: "gpu",
})
}
pdl = append(pdl, PFDeviceInfo{
Expand Down
2 changes: 2 additions & 0 deletions pkg/brgpu/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ func (p *Plugin) ListAndWatch(e *pluginapi.Empty, s pluginapi.DevicePlugin_ListA
}

func (p *Plugin) Allocate(ctx context.Context, r *pluginapi.AllocateRequest) (*pluginapi.AllocateResponse, error) {
logrus.Info("Allocate")
var current *v1.Pod
success := false
defer func() {
Expand Down Expand Up @@ -287,6 +288,7 @@ func (p *Plugin) Allocate(ctx context.Context, r *pluginapi.AllocateRequest) (*p
utils.PodAllocationFailed(GetNodeName(), current)
return nil, err
}
logrus.Infof("Allocate request %v", devreq)
if len(devreq) != len(req.DevicesIDs) {
utils.PodAllocationFailed(GetNodeName(), current)
return nil, fmt.Errorf("device number not matched")
Expand Down
4 changes: 2 additions & 2 deletions pkg/brgpu/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ func RegisterHAMiWithRawDevice(devs DevicesInfoList) error {
apiDevices := make([]*utils.DeviceInfo, 0, len(devs))
// hami currently believes that the index starts from 0 and is continuous.
index := 0
for i, dev := range devs {
for _, dev := range devs {
for _, ins := range dev.Instances {
device := &utils.DeviceInfo{
Index: uint(i),
Index: uint(index),
ID: ins.CardID,
Type: dev.Name,
Health: true,
Expand Down
2 changes: 1 addition & 1 deletion pkg/brgpu/runc.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ func DeviceDiscover() (DevicesInfoList, error) {
di.Instances = append(di.Instances, Instance{
UUID: fmt.Sprintf("%s-instance-%d", phyUUID, j),
Memory: int(mem.Total),
ResourceName: fmt.Sprintf("1-%d-gpu", sviCount),
ResourceName: "gpu",
CardID: cardIDFormat(id),
})
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/utils/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ var (
func init() {
InRequestDevices = make(map[string]string)
SupportDevices = make(map[string]string)
InRequestDevices[DeviceType] = "hami.io/Biren-devices-allocated"
InRequestDevices[DeviceType] = "hami.io/Biren-devices-to-allocate"
SupportDevices[DeviceType] = "hami.io/Biren-devices-allocated"
}

Expand Down
Loading