From 9faf11ddf3d2867a665de501a386d489fd748111 Mon Sep 17 00:00:00 2001 From: Evan Lezar Date: Wed, 23 Nov 2022 22:12:17 +0100 Subject: [PATCH 1/2] Fix error message Signed-off-by: Evan Lezar --- cmd/nvidia-ctk/cdi/generate/generate.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/nvidia-ctk/cdi/generate/generate.go b/cmd/nvidia-ctk/cdi/generate/generate.go index 4aa448e6..72d9180a 100644 --- a/cmd/nvidia-ctk/cdi/generate/generate.go +++ b/cmd/nvidia-ctk/cdi/generate/generate.go @@ -241,7 +241,7 @@ func (m command) generateSpec() (*specs.Spec, error) { graphicsEdits, err := m.editsForGraphicsDevice(nil) if err != nil { - return nil, fmt.Errorf("failed to generated edits for graphics libraries") + return nil, fmt.Errorf("failed to generate edits for graphics libraries: %v", err) } libOptions := []string{ From 5575b391ff4032cdbc297dbcce75faf77867558f Mon Sep 17 00:00:00 2001 From: Evan Lezar Date: Wed, 23 Nov 2022 21:49:02 +0100 Subject: [PATCH 2/2] Skip missing by-path symlinks instead of failing Signed-off-by: Evan Lezar --- internal/discover/graphics.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/internal/discover/graphics.go b/internal/discover/graphics.go index a6659a3a..99b2a70b 100644 --- a/internal/discover/graphics.go +++ b/internal/discover/graphics.go @@ -109,6 +109,13 @@ func (d drmDevicesByPath) Hooks() ([]Hook, error) { if len(devices) == 0 { return nil, nil } + links, err := d.getSpecificLinkArgs(devices) + if err != nil { + return nil, fmt.Errorf("failed to determine specific links: %v", err) + } + if len(links) == 0 { + return nil, nil + } hookPath := nvidiaCTKDefaultFilePath targets, err := d.lookup.Locate(d.nvidiaCTKExecutablePath) @@ -123,10 +130,6 @@ func (d drmDevicesByPath) Hooks() ([]Hook, error) { d.logger.Debugf("Using NVIDIA Container Toolkit CLI path %v", hookPath) args := []string{hookPath, "hook", "create-symlinks"} - links, err := d.getSpecificLinkArgs(devices) - if err != nil { - return nil, fmt.Errorf("failed to determine specific links: %v", err) - } for _, l := range links { args = append(args, "--link", l) } @@ -150,7 +153,8 @@ func (d drmDevicesByPath) getSpecificLinkArgs(devices []Device) ([]string, error linkLocator := lookup.NewFileLocator(d.logger, d.root) candidates, err := linkLocator.Locate("/dev/dri/by-path/pci-*-*") if err != nil { - return nil, fmt.Errorf("failed to locate devices by path: %v", err) + d.logger.Warningf("Failed to locate by-path links: %v; ignoring", err) + return nil, nil } var links []string