mirror of
https://github.com/docker/compose.git
synced 2025-07-23 21:54:40 +02:00
add support for CDI device request using devices
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
parent
f794c79eb3
commit
3a95a0872d
2
go.mod
2
go.mod
@ -57,6 +57,7 @@ require (
|
|||||||
google.golang.org/grpc v1.62.0
|
google.golang.org/grpc v1.62.0
|
||||||
gopkg.in/yaml.v3 v3.0.1
|
gopkg.in/yaml.v3 v3.0.1
|
||||||
gotest.tools/v3 v3.5.1
|
gotest.tools/v3 v3.5.1
|
||||||
|
tags.cncf.io/container-device-interface v0.8.0
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
@ -190,5 +191,4 @@ require (
|
|||||||
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
|
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
|
||||||
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
|
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
|
||||||
sigs.k8s.io/yaml v1.3.0 // indirect
|
sigs.k8s.io/yaml v1.3.0 // indirect
|
||||||
tags.cncf.io/container-device-interface v0.8.0 // indirect
|
|
||||||
)
|
)
|
||||||
|
@ -48,6 +48,7 @@ import (
|
|||||||
"github.com/docker/docker/errdefs"
|
"github.com/docker/docker/errdefs"
|
||||||
"github.com/docker/go-connections/nat"
|
"github.com/docker/go-connections/nat"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
|
cdi "tags.cncf.io/container-device-interface/pkg/parser"
|
||||||
)
|
)
|
||||||
|
|
||||||
type createOptions struct {
|
type createOptions struct {
|
||||||
@ -645,7 +646,14 @@ func getDeployResources(s types.ServiceConfig) container.Resources {
|
|||||||
setReservations(s.Deploy.Resources.Reservations, &resources)
|
setReservations(s.Deploy.Resources.Reservations, &resources)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var cdiDeviceNames []string
|
||||||
for _, device := range s.Devices {
|
for _, device := range s.Devices {
|
||||||
|
|
||||||
|
if device.Source == device.Target && cdi.IsQualifiedName(device.Source) {
|
||||||
|
cdiDeviceNames = append(cdiDeviceNames, device.Source)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
resources.Devices = append(resources.Devices, container.DeviceMapping{
|
resources.Devices = append(resources.Devices, container.DeviceMapping{
|
||||||
PathOnHost: device.Source,
|
PathOnHost: device.Source,
|
||||||
PathInContainer: device.Target,
|
PathInContainer: device.Target,
|
||||||
@ -653,6 +661,13 @@ func getDeployResources(s types.ServiceConfig) container.Resources {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(cdiDeviceNames) > 0 {
|
||||||
|
resources.DeviceRequests = append(resources.DeviceRequests, container.DeviceRequest{
|
||||||
|
Driver: "cdi",
|
||||||
|
DeviceIDs: cdiDeviceNames,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
ulimits := toUlimits(s.Ulimits)
|
ulimits := toUlimits(s.Ulimits)
|
||||||
resources.Ulimits = ulimits
|
resources.Ulimits = ulimits
|
||||||
return resources
|
return resources
|
||||||
|
Loading…
x
Reference in New Issue
Block a user