mirror of
https://github.com/containers/podman.git
synced 2025-06-21 01:19:15 +08:00
Fix handling of memory limits via varlink
Currently handlin memory via varlink is hard coded to 0 Changing to Memory: create.Resources.Memory, MemoryReservation: create.Resources.Memory_reservation, MemorySwap: create.Resources.Memory_swap, MemorySwappiness: int(create.Resources.Memory_swappiness), KernelMemory: create.Resources.Kernel_memory, Allows callers to modify these memory settings. Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
This commit is contained in:
@ -68,17 +68,11 @@ func (i *LibpodAPI) CreateContainer(call iopodman.VarlinkCall, config iopodman.C
|
|||||||
// varlinkCreateToCreateConfig takes the varlink input struct and maps it to a pointer
|
// varlinkCreateToCreateConfig takes the varlink input struct and maps it to a pointer
|
||||||
// of a CreateConfig, which eventually can be used to create the OCI spec.
|
// of a CreateConfig, which eventually can be used to create the OCI spec.
|
||||||
func varlinkCreateToCreateConfig(ctx context.Context, create iopodman.Create, runtime *libpod.Runtime, imageName string, data *inspect.ImageData) (*cc.CreateConfig, error) {
|
func varlinkCreateToCreateConfig(ctx context.Context, create iopodman.Create, runtime *libpod.Runtime, imageName string, data *inspect.ImageData) (*cc.CreateConfig, error) {
|
||||||
var (
|
|
||||||
inputCommand, command []string
|
|
||||||
memoryLimit, memoryReservation, memorySwap, memoryKernel int64
|
|
||||||
blkioWeight uint16
|
|
||||||
)
|
|
||||||
|
|
||||||
idmappings, err := util.ParseIDMapping(create.Uidmap, create.Gidmap, create.Subuidname, create.Subgidname)
|
idmappings, err := util.ParseIDMapping(create.Uidmap, create.Gidmap, create.Subuidname, create.Subgidname)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
inputCommand = create.Command
|
inputCommand := create.Command
|
||||||
entrypoint := create.Entrypoint
|
entrypoint := create.Entrypoint
|
||||||
|
|
||||||
// ENTRYPOINT
|
// ENTRYPOINT
|
||||||
@ -92,9 +86,7 @@ func varlinkCreateToCreateConfig(ctx context.Context, create iopodman.Create, ru
|
|||||||
}
|
}
|
||||||
// Build the command
|
// Build the command
|
||||||
// If we have an entry point, it goes first
|
// If we have an entry point, it goes first
|
||||||
if len(entrypoint) > 0 {
|
command := entrypoint
|
||||||
command = entrypoint
|
|
||||||
}
|
|
||||||
if len(inputCommand) > 0 {
|
if len(inputCommand) > 0 {
|
||||||
// User command overrides data CMD
|
// User command overrides data CMD
|
||||||
command = append(command, inputCommand...)
|
command = append(command, inputCommand...)
|
||||||
@ -103,10 +95,6 @@ func varlinkCreateToCreateConfig(ctx context.Context, create iopodman.Create, ru
|
|||||||
command = append(command, data.Config.Cmd...)
|
command = append(command, data.Config.Cmd...)
|
||||||
}
|
}
|
||||||
|
|
||||||
if create.Resources.Blkio_weight != 0 {
|
|
||||||
blkioWeight = uint16(create.Resources.Blkio_weight)
|
|
||||||
}
|
|
||||||
|
|
||||||
stopSignal := syscall.SIGTERM
|
stopSignal := syscall.SIGTERM
|
||||||
if create.Stop_signal > 0 {
|
if create.Stop_signal > 0 {
|
||||||
stopSignal, err = signal.ParseSignal(fmt.Sprintf("%d", create.Stop_signal))
|
stopSignal, err = signal.ParseSignal(fmt.Sprintf("%d", create.Stop_signal))
|
||||||
@ -183,7 +171,7 @@ func varlinkCreateToCreateConfig(ctx context.Context, create iopodman.Create, ru
|
|||||||
Quiet: create.Quiet,
|
Quiet: create.Quiet,
|
||||||
ReadOnlyRootfs: create.Readonly_rootfs,
|
ReadOnlyRootfs: create.Readonly_rootfs,
|
||||||
Resources: cc.CreateResourceConfig{
|
Resources: cc.CreateResourceConfig{
|
||||||
BlkioWeight: blkioWeight,
|
BlkioWeight: uint16(create.Resources.Blkio_weight),
|
||||||
BlkioWeightDevice: create.Resources.Blkio_weight_device,
|
BlkioWeightDevice: create.Resources.Blkio_weight_device,
|
||||||
CPUShares: uint64(create.Resources.Cpu_shares),
|
CPUShares: uint64(create.Resources.Cpu_shares),
|
||||||
CPUPeriod: uint64(create.Resources.Cpu_period),
|
CPUPeriod: uint64(create.Resources.Cpu_period),
|
||||||
@ -199,11 +187,11 @@ func varlinkCreateToCreateConfig(ctx context.Context, create iopodman.Create, ru
|
|||||||
DeviceWriteIOps: create.Resources.Device_write_iops,
|
DeviceWriteIOps: create.Resources.Device_write_iops,
|
||||||
DisableOomKiller: create.Resources.Disable_oomkiller,
|
DisableOomKiller: create.Resources.Disable_oomkiller,
|
||||||
ShmSize: create.Resources.Shm_size,
|
ShmSize: create.Resources.Shm_size,
|
||||||
Memory: memoryLimit,
|
Memory: create.Resources.Memory,
|
||||||
MemoryReservation: memoryReservation,
|
MemoryReservation: create.Resources.Memory_reservation,
|
||||||
MemorySwap: memorySwap,
|
MemorySwap: create.Resources.Memory_swap,
|
||||||
MemorySwappiness: int(create.Resources.Memory_swappiness),
|
MemorySwappiness: int(create.Resources.Memory_swappiness),
|
||||||
KernelMemory: memoryKernel,
|
KernelMemory: create.Resources.Kernel_memory,
|
||||||
OomScoreAdj: int(create.Resources.Oom_score_adj),
|
OomScoreAdj: int(create.Resources.Oom_score_adj),
|
||||||
PidsLimit: create.Resources.Pids_limit,
|
PidsLimit: create.Resources.Pids_limit,
|
||||||
Ulimit: create.Resources.Ulimit,
|
Ulimit: create.Resources.Ulimit,
|
||||||
|
Reference in New Issue
Block a user