summaryrefslogtreecommitdiff
path: root/libpod/options.go
diff options
context:
space:
mode:
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
+ }
+}