mirror of
https://github.com/psviderski/uncloud.git
synced 2026-08-26 11:03:34 +00:00
chore: refactor device mapping to be compliant with Compose (CDI requests)
This commit is contained in:
@@ -617,7 +617,7 @@ func (s *Server) CreateServiceContainer(
|
||||
NanoCPUs: spec.Container.Resources.CPU,
|
||||
Memory: spec.Container.Resources.Memory,
|
||||
MemoryReservation: spec.Container.Resources.MemoryReservation,
|
||||
Devices: spec.Container.Resources.DeviceMappings,
|
||||
Devices: toDockerDevices(spec.Container.Resources.Devices),
|
||||
DeviceRequests: spec.Container.Resources.DeviceReservations,
|
||||
Ulimits: toDockerUlimits(spec.Container.Resources.Ulimits),
|
||||
},
|
||||
@@ -897,6 +897,23 @@ func toDockerUlimits(ulimits map[string]api.Ulimit) []*units.Ulimit {
|
||||
return dockerUlimits
|
||||
}
|
||||
|
||||
func toDockerDevices(devices []api.DeviceMapping) []container.DeviceMapping {
|
||||
if len(devices) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
dockerDevices := make([]container.DeviceMapping, 0, len(devices))
|
||||
for _, d := range devices {
|
||||
dockerDevices = append(dockerDevices, container.DeviceMapping{
|
||||
PathOnHost: d.HostPath,
|
||||
PathInContainer: d.ContainerPath,
|
||||
CgroupPermissions: d.CgroupPermissions,
|
||||
})
|
||||
}
|
||||
|
||||
return dockerDevices
|
||||
}
|
||||
|
||||
// verifyDockerVolumesExist checks if the Docker named volumes referenced in the mounts exist on the machine.
|
||||
func (s *Server) verifyDockerVolumesExist(ctx context.Context, mounts []mount.Mount) error {
|
||||
for _, m := range mounts {
|
||||
|
||||
Reference in New Issue
Block a user