summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorCharlie Doern <cdoern@redhat.com>2022-06-28 12:11:29 -0400
committerCharlie Doern <cdoern@redhat.com>2022-07-01 13:44:32 -0400
commitb92149e2a8ce596b2839ec404e2ebd457943848f (patch)
tree1223e8b4594b40413a749c5d0025f5c4a6106f8a /libpod
parentb00e65aa9c071428579a55f91a92f3702765ed85 (diff)
downloadpodman-b92149e2a8ce596b2839ec404e2ebd457943848f.tar.gz
podman-b92149e2a8ce596b2839ec404e2ebd457943848f.tar.bz2
podman-b92149e2a8ce596b2839ec404e2ebd457943848f.zip
podman pod create --memory
using the new resource backend, implement podman pod create --memory which enables users to modify memory.max inside of the parent cgroup (the pod), implicitly impacting all children unless overriden Signed-off-by: Charlie Doern <cdoern@redhat.com>
Diffstat (limited to 'libpod')
-rw-r--r--libpod/define/pod_inspect.go2
-rw-r--r--libpod/pod.go17
-rw-r--r--libpod/pod_api.go1
3 files changed, 20 insertions, 0 deletions
diff --git a/libpod/define/pod_inspect.go b/libpod/define/pod_inspect.go
index c387856e5..935e0f5f9 100644
--- a/libpod/define/pod_inspect.go
+++ b/libpod/define/pod_inspect.go
@@ -69,6 +69,8 @@ type InspectPodData struct {
VolumesFrom []string `json:"volumes_from,omitempty"`
// SecurityOpt contains the specified security labels and related SELinux information
SecurityOpts []string `json:"security_opt,omitempty"`
+ // MemoryLimit contains the specified cgroup memory limit for the pod
+ MemoryLimit uint64 `json:"memory_limit,omitempty"`
}
// InspectPodInfraConfig contains the configuration of the pod's infra
diff --git a/libpod/pod.go b/libpod/pod.go
index 2502c41a9..c8c6790e8 100644
--- a/libpod/pod.go
+++ b/libpod/pod.go
@@ -169,6 +169,23 @@ func (p *Pod) CPUQuota() int64 {
return 0
}
+// MemoryLimit returns the pod Memory Limit
+func (p *Pod) MemoryLimit() uint64 {
+ if p.state.InfraContainerID == "" {
+ return 0
+ }
+ infra, err := p.runtime.GetContainer(p.state.InfraContainerID)
+ if err != nil {
+ return 0
+ }
+ conf := infra.config.Spec
+ if conf != nil && conf.Linux != nil && conf.Linux.Resources != nil && conf.Linux.Resources.Memory != nil && conf.Linux.Resources.Memory.Limit != nil {
+ val := *conf.Linux.Resources.Memory.Limit
+ return uint64(val)
+ }
+ return 0
+}
+
// NetworkMode returns the Network mode given by the user ex: pod, private...
func (p *Pod) NetworkMode() string {
infra, err := p.runtime.GetContainer(p.state.InfraContainerID)
diff --git a/libpod/pod_api.go b/libpod/pod_api.go
index fefe0e329..f06e62007 100644
--- a/libpod/pod_api.go
+++ b/libpod/pod_api.go
@@ -751,6 +751,7 @@ func (p *Pod) Inspect() (*define.InspectPodData, error) {
CPUSetCPUs: p.ResourceLim().CPU.Cpus,
CPUPeriod: p.CPUPeriod(),
CPUQuota: p.CPUQuota(),
+ MemoryLimit: p.MemoryLimit(),
Mounts: inspectMounts,
Devices: devices,
BlkioDeviceReadBps: deviceLimits,