Skip to content

Commit 5e0d8e0

Browse files
committed
default driver allocate rdmaCM device
Signed-off-by: bingshen.wbs <[email protected]>
1 parent f6d3884 commit 5e0d8e0

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

internal/agent/agent.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ func (a *Agent) Run() error {
9999
}
100100
}
101101
// 4. enable deviceplugin
102-
devicePlugin, err := deviceplugin.NewERDMADevicePlugin(erdmaDevices, a.allocAllDevices, a.devicepluginPreStart)
102+
devicePlugin, err := deviceplugin.NewERDMADevicePlugin(erdmaDevices, a.allocAllDevices, a.devicepluginPreStart, a.driver.Name() == "default")
103103
if err != nil {
104104
return fmt.Errorf("new erdma device plugin failed, err: %v", err)
105105
}

internal/deviceplugin/deviceplugin.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,12 @@ type ERDMADevicePlugin struct {
3737
devices map[string]*types.ERdmaDeviceInfo
3838
allocAllDevices bool
3939
devicepluginPreStart bool
40+
allocRdmaCM bool
4041
sync.Locker
4142
}
4243

4344
// NewERDMADevicePlugin returns an initialized ERDMADevicePlugin
44-
func NewERDMADevicePlugin(devices []*types.ERdmaDeviceInfo, allocAllDevices bool, devicepluginPreStart bool) (*ERDMADevicePlugin, error) {
45+
func NewERDMADevicePlugin(devices []*types.ERdmaDeviceInfo, allocAllDevices, devicepluginPreStart, allocRdmaCM bool) (*ERDMADevicePlugin, error) {
4546
devMap := map[string]*types.ERdmaDeviceInfo{}
4647
for _, d := range devices {
4748
devMap[d.Name] = d
@@ -60,6 +61,7 @@ func NewERDMADevicePlugin(devices []*types.ERdmaDeviceInfo, allocAllDevices bool
6061
Locker: &sync.Mutex{},
6162
allocAllDevices: allocAllDevices,
6263
devicepluginPreStart: devicepluginPreStart,
64+
allocRdmaCM: allocRdmaCM,
6365
stop: make(chan struct{}, 1),
6466
}, nil
6567
}
@@ -292,6 +294,13 @@ func (m *ERDMADevicePlugin) Allocate(ctx context.Context, r *pluginapi.AllocateR
292294
}
293295
})...)
294296
})
297+
if m.allocRdmaCM {
298+
devicePaths = append(devicePaths, &pluginapi.DeviceSpec{
299+
ContainerPath: "/dev/infiniband/rdma_cm",
300+
HostPath: "/dev/infiniband/rdma_cm",
301+
Permissions: "rw",
302+
})
303+
}
295304
if len(devicePaths) > 0 {
296305
response.ContainerResponses = append(response.ContainerResponses,
297306
&pluginapi.ContainerAllocateResponse{

0 commit comments

Comments
 (0)