mirror of
https://github.com/psviderski/uncloud.git
synced 2026-08-26 11:03:34 +00:00
* feat: add support for ulimits in compose and container creation ([#221](https://github.com/ipaddicting/uncloud/issues/221)) * refactor: move Ulimits to ContainerResources and use map, also removed GEMINI.md.
This commit is contained in:
@@ -125,6 +125,7 @@ func resourcesFromCompose(service types.ServiceConfig) api.ContainerResources {
|
||||
CPU: int64(service.CPUS * 1e9),
|
||||
Memory: int64(service.MemLimit),
|
||||
MemoryReservation: int64(service.MemReservation),
|
||||
Ulimits: ulimitsFromCompose(service.Ulimits),
|
||||
}
|
||||
|
||||
// Convert GPU device requests from compose format, appending "gpu" capability.
|
||||
@@ -293,6 +294,33 @@ func tmpfsVolumeSpecFromCompose(serviceVolume types.ServiceVolumeConfig) api.Vol
|
||||
return spec
|
||||
}
|
||||
|
||||
func ulimitsFromCompose(ulimits map[string]*types.UlimitsConfig) map[string]api.Ulimit {
|
||||
if len(ulimits) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
res := make(map[string]api.Ulimit, len(ulimits))
|
||||
for name, u := range ulimits {
|
||||
soft := u.Soft
|
||||
hard := u.Hard
|
||||
if u.Single != 0 {
|
||||
if soft == 0 {
|
||||
soft = u.Single
|
||||
}
|
||||
if hard == 0 {
|
||||
hard = u.Single
|
||||
}
|
||||
}
|
||||
|
||||
res[name] = api.Ulimit{
|
||||
Soft: int64(soft),
|
||||
Hard: int64(hard),
|
||||
}
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
// validateServicesExtensions validates extension combinations across all services in the project.
|
||||
func validateServicesExtensions(project *types.Project) error {
|
||||
for _, service := range project.Services {
|
||||
|
||||
Reference in New Issue
Block a user