mirror of
https://github.com/NVIDIA/nvidia-container-toolkit
synced 2024-11-22 00:08:11 +00:00
Generate a simplified CDI spec by default
As simplified CDI spec has no duplicate entities in any single set of container edits. Furthermore, contianer edits defined at a spec-level are not included in the container edits for a device. Signed-off-by: Evan Lezar <elezar@nvidia.com>
This commit is contained in:
parent
5ff206e1a9
commit
33f6fe0217
@ -2,6 +2,7 @@
|
||||
|
||||
## v1.13.0-rc.3
|
||||
|
||||
* 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.
|
||||
|
@ -19,6 +19,7 @@ package spec
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/NVIDIA/nvidia-container-toolkit/pkg/nvcdi/transform"
|
||||
"github.com/container-orchestrated-devices/container-device-interface/pkg/cdi"
|
||||
"github.com/container-orchestrated-devices/container-device-interface/specs-go"
|
||||
)
|
||||
@ -31,6 +32,7 @@ type builder struct {
|
||||
deviceSpecs []specs.Device
|
||||
edits specs.ContainerEdits
|
||||
format string
|
||||
noSimplify bool
|
||||
}
|
||||
|
||||
// newBuilder creates a new spec builder with the supplied options
|
||||
@ -76,6 +78,13 @@ func (o *builder) Build() (*spec, error) {
|
||||
raw.Version = minVersion
|
||||
}
|
||||
|
||||
if !o.noSimplify {
|
||||
err := transform.NewSimplifier().Transform(raw)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to simplify spec: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
s := spec{
|
||||
Spec: raw,
|
||||
format: o.format,
|
||||
@ -128,3 +137,10 @@ func WithFormat(format string) Option {
|
||||
o.format = format
|
||||
}
|
||||
}
|
||||
|
||||
// WithNoSimplify sets whether the spec must be simplified
|
||||
func WithNoSimplify(noSimplify bool) Option {
|
||||
return func(o *builder) {
|
||||
o.noSimplify = noSimplify
|
||||
}
|
||||
}
|
||||
|
@ -28,8 +28,8 @@ var _ Transformer = (*simplify)(nil)
|
||||
|
||||
// NewSimplifier creates a simplifier transformer.
|
||||
// This transoformer ensures that entities in the spec are deduplicated and that common edits are removed from device-specific edits.
|
||||
func NewSimplifier() (Transformer, error) {
|
||||
return &simplify{}, nil
|
||||
func NewSimplifier() Transformer {
|
||||
return &simplify{}
|
||||
}
|
||||
|
||||
// Transform simplifies the supplied spec.
|
||||
|
Loading…
Reference in New Issue
Block a user