runtime: add cause to CDI errors

Adding devices by CDI annotation can fail for a variety of reasons. If
that happens, it's helpful to know the root cause of the issue (CDI spec
missing, malformatted, requested device not present, etc.).

This commit adds the root cause of the CDI device addition to the errors
reported back to the caller. Since this error is bubbled up all the way
back to the shimv2 task.Create handler, it will be visible in Kubernetes
logs and enable fixing the root cause.

Signed-off-by: Markus Rudy <mr@edgeless.systems>
This commit is contained in:
Markus Rudy 2025-02-26 08:36:15 +01:00
parent 04c56a0aaf
commit 1f6833bd0d
2 changed files with 2 additions and 2 deletions

View File

@ -123,7 +123,7 @@ func create(ctx context.Context, s *service, r *taskAPI.CreateTaskRequest) (*con
if containerType == vc.SingleContainer {
_, err = config.WithCDI(ociSpec.Annotations, []string{}, ociSpec)
if err != nil {
return nil, fmt.Errorf("adding CDI devices failed")
return nil, fmt.Errorf("adding CDI devices failed: %w", err)
}
}

View File

@ -742,7 +742,7 @@ func (s *Sandbox) coldOrHotPlugVFIO(sandboxConfig *SandboxConfig) (bool, error)
//
_, err := config.WithCDI(cdiSpec.Annotations, []string{}, cdiSpec)
if err != nil {
return coldPlugVFIO, fmt.Errorf("adding CDI devices failed")
return coldPlugVFIO, fmt.Errorf("adding CDI devices failed: %w", err)
}
for _, dev := range cdiSpec.Linux.Devices {