fix: load the CDI driver before the dockerd daemon starts

Signed-off-by: Rafael Fernández López <ereslibre@ereslibre.es>
This commit is contained in:
Rafael Fernández López
2025-05-15 11:28:20 +02:00
parent c4dc09eac1
commit 8e57a019dc

View File

@@ -244,6 +244,17 @@ func (cli *daemonCLI) start(ctx context.Context) (err error) {
pluginStore := plugin.NewStore()
// Register the CDI driver before the daemon starts, as it might try to restore containers that depend on the CDI driver.
// Note that CDI is not inherently linux-specific, there are some linux-specific assumptions / implementations in the code that
// queries the properties of device on the host as well as performs the injection of device nodes and their access permissions into the OCI spec.
//
// In order to lift this restriction the following would have to be addressed:
// - Support needs to be added to the cdi package for injecting Windows devices: https://tags.cncf.io/container-device-interface/issues/28
// - The DeviceRequests API must be extended to non-linux platforms.
if runtime.GOOS == "linux" && cli.Config.Features["cdi"] {
daemon.RegisterCDIDriver(cli.Config.CDISpecDirs...)
}
var apiServer apiserver.Server
cli.authzMiddleware, err = initMiddlewares(ctx, &apiServer, cli.Config, pluginStore)
if err != nil {
@@ -262,16 +273,6 @@ func (cli *daemonCLI) start(ctx context.Context) (err error) {
return errors.Wrap(err, "failed to validate authorization plugin")
}
// Note that CDI is not inherently linux-specific, there are some linux-specific assumptions / implementations in the code that
// queries the properties of device on the host as well as performs the injection of device nodes and their access permissions into the OCI spec.
//
// In order to lift this restriction the following would have to be addressed:
// - Support needs to be added to the cdi package for injecting Windows devices: https://tags.cncf.io/container-device-interface/issues/28
// - The DeviceRequests API must be extended to non-linux platforms.
if runtime.GOOS == "linux" && cli.Config.Features["cdi"] {
daemon.RegisterCDIDriver(cli.Config.CDISpecDirs...)
}
cli.d = d
if err := startMetricsServer(cli.Config.MetricsAddress); err != nil {