Skip to content

Commit

Permalink
Merge pull request #423 from traylenator/fat
Browse files Browse the repository at this point in the history
Allow CPUQuota to be greater than 100%
  • Loading branch information
ekohl authored Mar 5, 2024
2 parents e1ca9c5 + cc32f4d commit 259896e
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 4 deletions.
4 changes: 2 additions & 2 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2632,7 +2632,7 @@ Struct[{
Optional['CPUAccounting'] => Boolean,
Optional['CPUShares'] => Integer[2,262144],
Optional['StartupCPUShares'] => Integer[2,262144],
Optional['CPUQuota'] => Systemd::Unit::Percent,
Optional['CPUQuota'] => Pattern['^([1-9][0-9]*)%$'], # bigger than 100% is okay.
Optional['MemoryAccounting'] => Boolean,
Optional['MemoryLow'] => Systemd::Unit::AmountOrPercent,
Optional['MemoryMin'] => Systemd::Unit::AmountOrPercent,
Expand Down Expand Up @@ -2737,7 +2737,7 @@ Alias of
```puppet
Struct[{
Optional['CPUAccounting'] => Boolean,
Optional['CPUQuota'] => Systemd::Unit::Percent,
Optional['CPUQuota'] => Pattern['^([1-9][0-9]*)%$'], # bigger than 100% is okay.
Optional['CPUShares'] => Integer[2,262144],
Optional['CPUWeight'] => Variant[Enum['idle'],Integer[1,10000]],
Optional['Delegate'] => Boolean,
Expand Down
5 changes: 5 additions & 0 deletions spec/type_aliases/systemd_unit_service_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@

it { is_expected.to allow_value({ 'MemoryAccounting' => true }) }

it { is_expected.to allow_value({ 'CPUQuota' => '1%' }) }
it { is_expected.to allow_value({ 'CPUQuota' => '110%' }) }

it {
is_expected.to allow_value(
{
Expand All @@ -100,5 +103,7 @@
)
}

it { is_expected.not_to allow_value({ 'CPUQuota' => 50 }) }
it { is_expected.not_to allow_value({ 'CPUQuota' => '0%' }) }
it { is_expected.not_to allow_value({ 'MemoryHigh' => '1Y' }) }
end
4 changes: 4 additions & 0 deletions spec/type_aliases/systemd_unit_slice_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
describe 'Systemd::Unit::Slice' do
it { is_expected.to allow_value({ 'MemoryAccounting' => true }) }
it { is_expected.to allow_value({ 'CPUWeight' => 100 }) }
it { is_expected.to allow_value({ 'CPUQuota' => '1%' }) }
it { is_expected.to allow_value({ 'CPUQuota' => '110%' }) }
it { is_expected.to allow_value({ 'CPUWeight' => 'idle' }) }
it { is_expected.to allow_value({ 'IPAccounting' => true }) }
it { is_expected.to allow_value({ 'IOAccounting' => false }) }
Expand All @@ -26,5 +28,7 @@
)
}

it { is_expected.not_to allow_value({ 'CPUQuota' => 50 }) }
it { is_expected.not_to allow_value({ 'CPUQuota' => '0%' }) }
it { is_expected.not_to allow_value({ 'MemoryHigh' => '1Y' }) }
end
2 changes: 1 addition & 1 deletion types/unit/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
Optional['CPUAccounting'] => Boolean,
Optional['CPUShares'] => Integer[2,262144],
Optional['StartupCPUShares'] => Integer[2,262144],
Optional['CPUQuota'] => Systemd::Unit::Percent,
Optional['CPUQuota'] => Pattern['^([1-9][0-9]*)%$'], # bigger than 100% is okay.
Optional['MemoryAccounting'] => Boolean,
Optional['MemoryLow'] => Systemd::Unit::AmountOrPercent,
Optional['MemoryMin'] => Systemd::Unit::AmountOrPercent,
Expand Down
2 changes: 1 addition & 1 deletion types/unit/slice.pp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
type Systemd::Unit::Slice = Struct[
{
Optional['CPUAccounting'] => Boolean,
Optional['CPUQuota'] => Systemd::Unit::Percent,
Optional['CPUQuota'] => Pattern['^([1-9][0-9]*)%$'], # bigger than 100% is okay.
Optional['CPUShares'] => Integer[2,262144],
Optional['CPUWeight'] => Variant[Enum['idle'],Integer[1,10000]],
Optional['Delegate'] => Boolean,
Expand Down

0 comments on commit 259896e

Please sign in to comment.