Merge pull request #10276 from Apokleos/fix-runtime-cdi

runtime: Fix runtime/cdi panic with assignment to entry in nil map
This commit is contained in:
Alex Lyn 2024-09-11 09:00:11 +08:00 committed by GitHub
commit d0968032f7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1010,6 +1010,9 @@ func (c *Container) siblingAnnotation(devPath string, siblings []DeviceRelation)
vfioNum := filepath.Base(devPath)
annoKey := fmt.Sprintf("cdi.k8s.io/vfio%s", vfioNum)
annoValue := fmt.Sprintf("nvidia.com/gpu=%d", sibling.Index)
if c.config.CustomSpec.Annotations == nil {
c.config.CustomSpec.Annotations = make(map[string]string)
}
c.config.CustomSpec.Annotations[annoKey] = annoValue
c.Logger().Infof("annotated container with %s: %s", annoKey, annoValue)
}