Add ctr support for CPUMax and CPUShares
Adds CPU.Maximum and CPU.Shares support to the ctr cmdline for testing Signed-off-by: Justin Terry <jlterry@amazon.com>
This commit is contained in:
@@ -83,6 +83,10 @@ func setResources(s *Spec) {
|
||||
s.Linux.Resources = &specs.LinuxResources{}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// nolint
|
||||
func setResourcesWindows(s *Spec) {
|
||||
if s.Windows != nil {
|
||||
if s.Windows.Resources == nil {
|
||||
s.Windows.Resources = &specs.WindowsResources{}
|
||||
@@ -98,6 +102,11 @@ func setCPU(s *Spec) {
|
||||
s.Linux.Resources.CPU = &specs.LinuxCPU{}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// nolint
|
||||
func setCPUWindows(s *Spec) {
|
||||
setResourcesWindows(s)
|
||||
if s.Windows != nil {
|
||||
if s.Windows.Resources.CPU == nil {
|
||||
s.Windows.Resources.CPU = &specs.WindowsCPUResources{}
|
||||
|
||||
@@ -31,17 +31,32 @@ import (
|
||||
// `count` specified.
|
||||
func WithWindowsCPUCount(count uint64) SpecOpts {
|
||||
return func(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
|
||||
if s.Windows.Resources == nil {
|
||||
s.Windows.Resources = &specs.WindowsResources{}
|
||||
}
|
||||
if s.Windows.Resources.CPU == nil {
|
||||
s.Windows.Resources.CPU = &specs.WindowsCPUResources{}
|
||||
}
|
||||
setCPUWindows(s)
|
||||
s.Windows.Resources.CPU.Count = &count
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// WithWindowsCPUShares sets the `Windows.Resources.CPU.Shares` section to the
|
||||
// `shares` specified.
|
||||
func WithWindowsCPUShares(shares uint16) SpecOpts {
|
||||
return func(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
|
||||
setCPUWindows(s)
|
||||
s.Windows.Resources.CPU.Shares = &shares
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// WithWindowsCPUMaximum sets the `Windows.Resources.CPU.Maximum` section to the
|
||||
// `max` specified.
|
||||
func WithWindowsCPUMaximum(max uint16) SpecOpts {
|
||||
return func(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
|
||||
setCPUWindows(s)
|
||||
s.Windows.Resources.CPU.Maximum = &max
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// WithWindowsIgnoreFlushesDuringBoot sets `Windows.IgnoreFlushesDuringBoot`.
|
||||
func WithWindowsIgnoreFlushesDuringBoot() SpecOpts {
|
||||
return func(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
|
||||
|
||||
Reference in New Issue
Block a user