From 97f4bcb456eaeec4fb2f78d093281a1ac64a5832 Mon Sep 17 00:00:00 2001 From: Zvonko Kaiser Date: Mon, 14 Apr 2025 19:09:30 +0000 Subject: [PATCH] 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 --- src/runtime/pkg/device/config/config.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/runtime/pkg/device/config/config.go b/src/runtime/pkg/device/config/config.go index d2f6d8928..42bcccff8 100644 --- a/src/runtime/pkg/device/config/config.go +++ b/src/runtime/pkg/device/config/config.go @@ -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