Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow CPUQuota to be greater than 100% #423

Merged
merged 1 commit into from
Mar 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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