mirror of
https://github.com/NVIDIA/nvidia-container-toolkit
synced 2024-11-22 00:08:11 +00:00
Also return an error from nvcdi.New
This change allows nvcdi.New to return an error in addition to the constructed library instead of panicing. Signed-off-by: Evan Lezar <elezar@nvidia.com>
This commit is contained in:
parent
1ebbebf5de
commit
226c54613e
@ -2,11 +2,12 @@
|
||||
|
||||
## v1.13.0-rc.3
|
||||
|
||||
* Also return an error from the nvcdi.New constructor instead of panicing.
|
||||
* Generate a simplified CDI specification by default. This means that entities in the common edits in a spec are not included in device definitions.
|
||||
* Add transformers to deduplicate and simplify CDI specifications.
|
||||
* Fix the generation of CDI specifications for management containers when the driver libraries are not in the LDCache.
|
||||
* Prefer /run over /var/run when locating nvidia-persistenced and nvidia-fabricmanager sockets.
|
||||
* Only initialize NVML for modes that require it when runing `nvidia-ctk cdi generate`
|
||||
* Only initialize NVML for modes that require it when runing `nvidia-ctk cdi generate`.
|
||||
* [libnvidia-container] Fix segmentation fault when RPC initialization fails.
|
||||
* [libnvidia-container] Build centos variants of the NVIDIA Container Library with static libtirpc v1.3.2.
|
||||
* [libnvidia-container] Remove make targets for fedora35 as the centos8 packages are compatible.
|
||||
|
@ -188,13 +188,16 @@ func (m command) generateSpec(cfg *config) (spec.Interface, error) {
|
||||
return nil, fmt.Errorf("failed to create device namer: %v", err)
|
||||
}
|
||||
|
||||
cdilib := nvcdi.New(
|
||||
cdilib, err := nvcdi.New(
|
||||
nvcdi.WithLogger(m.logger),
|
||||
nvcdi.WithDriverRoot(cfg.driverRoot),
|
||||
nvcdi.WithNVIDIACTKPath(cfg.nvidiaCTKPath),
|
||||
nvcdi.WithDeviceNamer(deviceNamer),
|
||||
nvcdi.WithMode(string(cfg.mode)),
|
||||
)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to create CDI library: %v", err)
|
||||
}
|
||||
|
||||
deviceSpecs, err := cdilib.GetAllDeviceSpecs()
|
||||
if err != nil {
|
||||
|
@ -49,7 +49,7 @@ type nvcdilib struct {
|
||||
}
|
||||
|
||||
// New creates a new nvcdi library
|
||||
func New(opts ...Option) Interface {
|
||||
func New(opts ...Option) (Interface, error) {
|
||||
l := &nvcdilib{}
|
||||
for _, opt := range opts {
|
||||
opt(l)
|
||||
@ -102,8 +102,7 @@ func New(opts ...Option) Interface {
|
||||
}
|
||||
lib = (*mofedlib)(l)
|
||||
default:
|
||||
// TODO: We would like to return an error here instead of panicking
|
||||
panic("Unknown mode")
|
||||
return nil, fmt.Errorf("unknown mode %q", l.mode)
|
||||
}
|
||||
|
||||
w := wrapper{
|
||||
@ -111,7 +110,7 @@ func New(opts ...Option) Interface {
|
||||
vendor: l.vendor,
|
||||
class: l.class,
|
||||
}
|
||||
return &w
|
||||
return &w, nil
|
||||
}
|
||||
|
||||
// GetSpec combines the device specs and common edits from the wrapped Interface to a single spec.Interface.
|
||||
|
@ -608,13 +608,16 @@ func generateCDISpec(opts *options, nvidiaCTKPath string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
cdilib := nvcdi.New(
|
||||
cdilib, err := nvcdi.New(
|
||||
nvcdi.WithMode(nvcdi.ModeManagement),
|
||||
nvcdi.WithDriverRoot(opts.DriverRootCtrPath),
|
||||
nvcdi.WithNVIDIACTKPath(nvidiaCTKPath),
|
||||
nvcdi.WithVendor(opts.cdiVendor),
|
||||
nvcdi.WithClass(opts.cdiClass),
|
||||
)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to create CDI library for management containers: %v", err)
|
||||
}
|
||||
|
||||
spec, err := cdilib.GetSpec()
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user