gpu: Remove CDI annotations for outer runtime

After the outer runtime has processed the CDI annotation from the
spec we can delete them since they were converted into Linux
devices in the OCI spec.

Signed-off-by: Zvonko Kaiser <zkaiser@nvidia.com>
This commit is contained in:
Zvonko Kaiser 2025-04-14 19:09:30 +00:00
parent 6102976d2d
commit 97f4bcb456

View File

@ -697,7 +697,14 @@ func WithCDI(annotations map[string]string, cdiSpecDirs []string, spec *specs.Sp
if _, err := registry.InjectDevices(spec, devsFromAnnotations...); err != nil {
return nil, fmt.Errorf("CDI device injection failed: %w", err)
}
// Once we injected the device into the ociSpec we do not need to CDI
// device annotation from the outer runtime. The runtime will create the
// appropriate inner runtime CDI annotation dependent on the device.
for key := range spec.Annotations {
if strings.HasPrefix(key, cdi.AnnotationPrefix) {
delete(spec.Annotations, key)
}
}
// One crucial thing to keep in mind is that CDI device injection
// might add OCI Spec environment variables, hooks, and mounts as
// well. Therefore it is important that none of the corresponding