pkg/nvidia: Share the Logrus logger with the info.Interface
A new API was added to github.com/NVIDIA/go-nvlib 0.4.0 to specify a
logger to be used by a info.Interface [1]. Commit 649d02f8a6
already bumped the required go-nvlib version to 0.6.0, so take advantage
of that.
[1] github.com/NVIDIA/go-nvlib commit 21c8f035ca66b29d
https://github.com/NVIDIA/go-nvlib/commit/21c8f035ca66b29d
https://github.com/NVIDIA/go-nvlib/pull/28
https://github.com/containers/toolbox/pull/1541
This commit is contained in:
parent
ce7a0d4ce2
commit
09dcdb492a
|
|
@ -45,7 +45,14 @@ func createNullLogger() *logrus.Logger {
|
|||
func GenerateCDISpec() (*specs.Spec, error) {
|
||||
logrus.Debugf("Generating Container Device Interface for NVIDIA")
|
||||
|
||||
info := info.New()
|
||||
var logger *logrus.Logger
|
||||
if logLevel < logrus.DebugLevel {
|
||||
logger = createNullLogger()
|
||||
} else {
|
||||
logger = logrus.StandardLogger()
|
||||
}
|
||||
|
||||
info := info.New(info.WithLogger(logger))
|
||||
|
||||
if ok, reason := info.HasDXCore(); ok {
|
||||
logrus.Debugf("Generating Container Device Interface for NVIDIA: Windows is unsupported: %s", reason)
|
||||
|
|
@ -67,13 +74,6 @@ func GenerateCDISpec() (*specs.Spec, error) {
|
|||
return nil, ErrPlatformUnsupported
|
||||
}
|
||||
|
||||
var logger *logrus.Logger
|
||||
if logLevel < logrus.DebugLevel {
|
||||
logger = createNullLogger()
|
||||
} else {
|
||||
logger = logrus.StandardLogger()
|
||||
}
|
||||
|
||||
cdi, err := nvcdi.New(nvcdi.WithInfoLib(info), nvcdi.WithLogger(logger))
|
||||
if err != nil {
|
||||
logrus.Debugf("Generating Container Device Interface for NVIDIA: failed to create library: %s", err)
|
||||
|
|
|
|||
Loading…
Reference in New Issue