Skip to content

Commit b7a508a

Browse files
committed
Remove redundant CDI annotations
When generating CDI specs for coherent and noncoherent devices, we include CDI device annotations. This increases the minimum CDI spec version to v0.6.0 which is not as widely supported as v0.5.0 or v0.3.0. This change removes these annotations after splitting the generated specs to produce coherent and/or non-coherent specs. Signed-off-by: Evan Lezar <[email protected]>
1 parent 77e8f4b commit b7a508a

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

cmd/nvidia-ctk/cdi/generate/generate.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,7 @@ type deviceSpecs []specs.Device
447447
func (d deviceSpecs) splitOnAnnotation(key string) map[string][]specs.Device {
448448
splitSpecs := make(map[string][]specs.Device)
449449

450+
var specsToRemoveAnnotations []*specs.Device
450451
for _, deviceSpec := range d {
451452
if len(deviceSpec.Annotations) == 0 {
452453
continue
@@ -456,6 +457,21 @@ func (d deviceSpecs) splitOnAnnotation(key string) map[string][]specs.Device {
456457
continue
457458
}
458459
splitSpecs[key+"="+value] = append(splitSpecs[key+"="+value], deviceSpec)
460+
specsToRemoveAnnotations = append(specsToRemoveAnnotations, &deviceSpec)
461+
}
462+
463+
// We also remove the annotations that were used to split the devices:
464+
for _, deviceSpec := range specsToRemoveAnnotations {
465+
if len(deviceSpec.Annotations) == 0 {
466+
continue
467+
}
468+
if _, ok := deviceSpec.Annotations[key]; !ok {
469+
continue
470+
}
471+
delete(deviceSpec.Annotations, key)
472+
if len(deviceSpec.Annotations) == 0 {
473+
deviceSpec.Annotations = nil
474+
}
459475
}
460476

461477
return splitSpecs

0 commit comments

Comments
 (0)