Skip to content

Commit 5374208

Browse files
committed
fpga: use CDI to run hooks
1 parent ec0b048 commit 5374208

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

cmd/fpga_plugin/fpga_plugin.go

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424

2525
"k8s.io/klog/v2"
2626
pluginapi "k8s.io/kubelet/pkg/apis/deviceplugin/v1beta1"
27+
cdispec "tags.cncf.io/container-device-interface/specs-go"
2728

2829
dpapi "github.com/intel/intel-device-plugins-for-kubernetes/pkg/deviceplugin"
2930
"github.com/intel/intel-device-plugins-for-kubernetes/pkg/fpga"
@@ -50,6 +51,10 @@ const (
5051

5152
// Period of device scans.
5253
scanPeriod = 5 * time.Second
54+
55+
// CDI hook attributes.
56+
HookName = "prestart"
57+
HookPath = "/opt/intel/fpga-sw/intel-fpga-crihook"
5358
)
5459

5560
type newPortFunc func(fname string) (fpga.Port, error)
@@ -83,7 +88,14 @@ func getRegionDevelTree(devices []device) dpapi.DeviceTree {
8388
Permissions: "rw",
8489
}
8590

86-
regionTree.AddDevice(devType, region.id, dpapi.NewDeviceInfo(health, devNodes, nil, nil, nil, nil))
91+
hooks := []*cdispec.Hook{
92+
{
93+
HookName: HookName,
94+
Path: HookPath,
95+
},
96+
}
97+
98+
regionTree.AddDevice(devType, region.id, dpapi.NewDeviceInfo(health, devNodes, nil, nil, nil, hooks))
8799
}
88100
}
89101

@@ -112,7 +124,14 @@ func getRegionTree(devices []device) dpapi.DeviceTree {
112124
}
113125
}
114126

115-
regionTree.AddDevice(devType, region.id, dpapi.NewDeviceInfo(health, devNodes, nil, nil, nil, nil))
127+
hooks := []*cdispec.Hook{
128+
{
129+
HookName: HookName,
130+
Path: HookPath,
131+
},
132+
}
133+
134+
regionTree.AddDevice(devType, region.id, dpapi.NewDeviceInfo(health, devNodes, nil, nil, nil, hooks))
116135
}
117136
}
118137

0 commit comments

Comments
 (0)