CDI: configure registry on start
Currently CDI registry is reconfigured on every WithCDI call, which is a relatively heavy operation. This happens because cdi.GetRegistry(cdi.WithSpecDirs(cdiSpecDirs...)) unconditionally reconfigures the registry (clears fs notify watch, sets up new watch, rescans directories). Moving configuration to the criService.initPlatform should result in performing registry configuration only once on the service start. Signed-off-by: Ed Bartosh <eduard.bartosh@intel.com>
This commit is contained in:
@@ -19,6 +19,7 @@ package server
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/container-orchestrated-devices/container-device-interface/pkg/cdi"
|
||||
"github.com/containerd/containerd/pkg/cap"
|
||||
"github.com/containerd/containerd/pkg/userns"
|
||||
cni "github.com/containerd/go-cni"
|
||||
@@ -87,6 +88,14 @@ func (c *criService) initPlatform() (err error) {
|
||||
}
|
||||
}
|
||||
|
||||
if c.config.EnableCDI {
|
||||
reg := cdi.GetRegistry()
|
||||
err = reg.Configure(cdi.WithSpecDirs(c.config.CDISpecDirs...))
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to configure CDI registry")
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user