Skip to content

Commit c7f88bd

Browse files
authored
Merge pull request #22 from ttsuuubasa/cohdi-dev
refactor: remove hardcoded GPU device type and use configurable attributes
2 parents cdaf186 + 8effdd2 commit c7f88bd

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

pkg/manager/manager.go

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

4040
const (
4141
configMapName = "composable-dra/composable-dra-dds"
42-
GpuDeviceType = "gpu"
4342
)
4443

4544
type CDIManager struct {
@@ -537,12 +536,8 @@ func (m *CDIManager) generatePool(device *device, fabricID int, generation int64
537536
var devices []resourceapi.Device
538537
for i := 0; i < device.availableDeviceCount; i++ {
539538
d := resourceapi.Device{
540-
Name: fmt.Sprintf("%s-gpu%d", device.k8sDeviceName, i),
541-
Attributes: map[resourceapi.QualifiedName]resourceapi.DeviceAttribute{
542-
"type": {
543-
StringValue: ptr.To(GpuDeviceType),
544-
},
545-
},
539+
Name: fmt.Sprintf("%s-%d", device.k8sDeviceName, i),
540+
Attributes: make(map[resourceapi.QualifiedName]resourceapi.DeviceAttribute),
546541
BindsToNode: ptr.To(true),
547542
BindingConditions: []string{"FabricDeviceReady"},
548543
BindingFailureConditions: []string{"FabricDeviceReschedule", "FabricDeviceFailed"},

pkg/manager/manager_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,7 @@ func TestCheckResourcePoolLoop(t *testing.T) {
650650
}
651651
var deviceFound bool
652652
for _, device := range resourceslice.Spec.Devices {
653-
if len(tc.expectedDeviceName) > 0 && device.Name == tc.expectedDeviceName+"-gpu0" {
653+
if len(tc.expectedDeviceName) > 0 && device.Name == tc.expectedDeviceName+"-0" {
654654
deviceFound = true
655655
for expectedKey, expectedValue := range tc.expectedAttributes {
656656
value := device.Attributes[resourceapi.QualifiedName(expectedKey)]
@@ -1176,7 +1176,7 @@ func TestCDIManagerManageCDIResourceSlices(t *testing.T) {
11761176
t.Errorf("unexpected device num, expected %d but got %d", availableDevice, len(resourceslice.Spec.Devices))
11771177
}
11781178
for _, device := range resourceslice.Spec.Devices {
1179-
if device.Name == tc.expectedDeviceName+"-gpu0" {
1179+
if device.Name == tc.expectedDeviceName+"-0" {
11801180
deviceFound = true
11811181
productName := device.Attributes["productName"]
11821182
if productName.StringValue != nil && *productName.StringValue != tc.expectedProductName {
@@ -1313,7 +1313,7 @@ func TestCDIManagerGeneratePool(t *testing.T) {
13131313
"productName": "TEST DEVICE 1",
13141314
},
13151315
availableDeviceCount: 3,
1316-
expectedDeviceName: "test-device-1-gpu0",
1316+
expectedDeviceName: "test-device-1-0",
13171317
},
13181318
}
13191319
for _, tc := range testCases {

0 commit comments

Comments
 (0)