mirror of
				https://github.com/NVIDIA/nvidia-container-toolkit
				synced 2025-06-26 18:18:24 +00:00 
			
		
		
		
	Only use configured nvidia-ctk path if it is a full path
If this is not done, the default config which sets the nvidia-ctk.path option as "nvidia-ctk" will result in an invalid OCI spec if a hook is injected. This change ensures that the path used is always an absolute path as required by the hook spec. Signed-off-by: Evan Lezar <elezar@nvidia.com>
This commit is contained in:
		
							parent
							
								
									763e4936cd
								
							
						
					
					
						commit
						7045a223d2
					
				| @ -39,22 +39,24 @@ func CreateNvidiaCTKHook(executable string, hookName string, additionalArgs ...s | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // FindNvidiaCTK locates the nvidia-ctk executable to be used in hooks.
 | // FindNvidiaCTK locates the nvidia-ctk executable to be used in hooks.
 | ||||||
| // If an override is specified, this is used instead.
 | // If an nvidia-ctk path is specified as an absolute path, it is used directly
 | ||||||
| func FindNvidiaCTK(logger *logrus.Logger, override string) string { | // without checking for existence of an executable at that path.
 | ||||||
| 	if override != "" { | func FindNvidiaCTK(logger *logrus.Logger, nvidiaCTKPath string) string { | ||||||
| 		logger.Debugf("Using specified NVIDIA Container Toolkit CLI path %v", override) | 	if filepath.IsAbs(nvidiaCTKPath) { | ||||||
| 		return override | 		logger.Debugf("Using specified NVIDIA Container Toolkit CLI path %v", nvidiaCTKPath) | ||||||
|  | 		return nvidiaCTKPath | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | 	logger.Debugf("Locating NVIDIA Container Toolkit CLI as %v", nvidiaCTKPath) | ||||||
| 	lookup := lookup.NewExecutableLocator(logger, "") | 	lookup := lookup.NewExecutableLocator(logger, "") | ||||||
| 	hookPath := nvidiaCTKDefaultFilePath | 	hookPath := nvidiaCTKDefaultFilePath | ||||||
| 	targets, err := lookup.Locate(nvidiaCTKExecutable) | 	targets, err := lookup.Locate(nvidiaCTKPath) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		logger.Warnf("Failed to locate %v: %v", nvidiaCTKExecutable, err) | 		logger.Warnf("Failed to locate %v: %v", nvidiaCTKPath, err) | ||||||
| 	} else if len(targets) == 0 { | 	} else if len(targets) == 0 { | ||||||
| 		logger.Warnf("%v not found", nvidiaCTKExecutable) | 		logger.Warnf("%v not found", nvidiaCTKPath) | ||||||
| 	} else { | 	} else { | ||||||
| 		logger.Debugf("Found %v candidates: %v", nvidiaCTKExecutable, targets) | 		logger.Debugf("Found %v candidates: %v", nvidiaCTKPath, targets) | ||||||
| 		hookPath = targets[0] | 		hookPath = targets[0] | ||||||
| 	} | 	} | ||||||
| 	logger.Debugf("Using NVIDIA Container Toolkit CLI path %v", hookPath) | 	logger.Debugf("Using NVIDIA Container Toolkit CLI path %v", hookPath) | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user