summaryrefslogtreecommitdiff
path: root/libpod/options.go
diff options
context:
space:
mode:
authorcdoern <cbdoer23@g.holycross.edu>2021-06-17 17:36:35 -0400
committercdoern <cbdoer23@g.holycross.edu>2021-06-23 13:47:57 -0400
commitbbd085ad1e3cf9c5b543c907ad7014ccf8a5cb34 (patch)
tree14dd2d240f32586a624f6a786d8127b8bfb95017 /libpod/options.go
parent510509bafcdd055b4a6819ed300db7292c6fb6b8 (diff)
downloadpodman-bbd085ad1e3cf9c5b543c907ad7014ccf8a5cb34.tar.gz
podman-bbd085ad1e3cf9c5b543c907ad7014ccf8a5cb34.tar.bz2
podman-bbd085ad1e3cf9c5b543c907ad7014ccf8a5cb34.zip
Podman Pod Create --cpus and --cpuset-cpus flags
Added logic and handling for two new Podman pod create Flags. --cpus specifies the total number of cores on which the pod can execute, this is a combination of the period and quota for the CPU. --cpuset-cpus is a string value which determines of these available cores, how many we will truly execute on. Signed-off-by: cdoern <cbdoer23@g.holycross.edu>
Diffstat (limited to 'libpod/options.go')
-rw-r--r--libpod/options.go42
1 files changed, 40 insertions, 2 deletions
diff --git a/libpod/options.go b/libpod/options.go
index f2468e41b..b12153512 100644
--- a/libpod/options.go
+++ b/libpod/options.go
@@ -20,6 +20,7 @@ import (
"github.com/containers/storage"
"github.com/containers/storage/pkg/idtools"
"github.com/cri-o/ocicni/pkg/ocicni"
+ "github.com/opencontainers/runtime-spec/specs-go"
"github.com/opencontainers/runtime-tools/generate"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
@@ -559,7 +560,6 @@ func WithMaxLogSize(limit int64) CtrCreateOption {
if ctr.valid {
return define.ErrRuntimeFinalized
}
-
ctr.config.LogSize = limit
return nil
@@ -867,7 +867,6 @@ func WithMountNSFrom(nsCtr *Container) CtrCreateOption {
if err := checkDependencyContainer(nsCtr, ctr); err != nil {
return err
}
-
ctr.config.MountNsCtr = nsCtr.ID()
return nil
@@ -2359,3 +2358,42 @@ func WithVolatile() CtrCreateOption {
return nil
}
}
+
+// WithPodCPUPAQ takes the given cpu period and quota and inserts them in the proper place.
+func WithPodCPUPAQ(period uint64, quota int64) PodCreateOption {
+ return func(pod *Pod) error {
+ if pod.valid {
+ return define.ErrPodFinalized
+ }
+ if pod.CPUPeriod() != 0 && pod.CPUQuota() != 0 {
+ pod.config.InfraContainer.ResourceLimits.CPU = &specs.LinuxCPU{
+ Period: &period,
+ Quota: &quota,
+ }
+ } else {
+ pod.config.InfraContainer.ResourceLimits = &specs.LinuxResources{}
+ pod.config.InfraContainer.ResourceLimits.CPU = &specs.LinuxCPU{
+ Period: &period,
+ Quota: &quota,
+ }
+ }
+ return nil
+ }
+}
+
+// WithPodCPUSetCPUS computes and sets the Cpus linux resource string which determines the amount of cores, from those available, we are allowed to execute on
+func WithPodCPUSetCPUs(inp string) PodCreateOption {
+ return func(pod *Pod) error {
+ if pod.valid {
+ return define.ErrPodFinalized
+ }
+ if pod.ResourceLim().CPU.Period != nil {
+ pod.config.InfraContainer.ResourceLimits.CPU.Cpus = inp
+ } else {
+ pod.config.InfraContainer.ResourceLimits = &specs.LinuxResources{}
+ pod.config.InfraContainer.ResourceLimits.CPU = &specs.LinuxCPU{}
+ pod.config.InfraContainer.ResourceLimits.CPU.Cpus = inp
+ }
+ return nil
+ }
+}