Skip to content

Commit c3965db

Browse files
committed
Allow MemorySwapMax be specified as a percentage
A configuration of: ```config [Service] MemoryMax=80% MemorySwapMax=20% ``` seems to work: ``` systemctl status autofs.service Memory: 134.6M (max: 2.6G swap max: 336.2M available: 2.4G) ``` The systemd documentation was lacking this information so I've corrected that also. * https://www.freedesktop.org/software/systemd/man/latest/systemd.resource-control.html#MemorySwapMax=bytes * systemd/systemd#33593
1 parent aea425a commit c3965db

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

REFERENCE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2888,7 +2888,7 @@ Struct[{
28882888
Optional['MemoryHigh'] => Systemd::Unit::AmountOrPercent,
28892889
Optional['MemoryMax'] => Systemd::Unit::AmountOrPercent,
28902890
Optional['MemoryLimit'] => Systemd::Unit::Amount,
2891-
Optional['MemorySwapMax'] => Systemd::Unit::Amount,
2891+
Optional['MemorySwapMax'] => Systemd::Unit::AmountOrPercent,
28922892
Optional['TasksAccounting'] => Boolean,
28932893
Optional['TasksMax'] => Systemd::Unit::AmountOrPercent,
28942894
Optional['IOAccounting'] => Boolean,

spec/type_aliases/systemd_unit_service_spec.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@
103103
)
104104
}
105105

106+
it { is_expected.to allow_value({ 'MemorySwapMax' => '80%' }) }
107+
106108
it { is_expected.not_to allow_value({ 'CPUQuota' => 50 }) }
107109
it { is_expected.not_to allow_value({ 'CPUQuota' => '0%' }) }
108110
it { is_expected.not_to allow_value({ 'MemoryHigh' => '1Y' }) }

types/unit/service.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
Optional['MemoryHigh'] => Systemd::Unit::AmountOrPercent,
5858
Optional['MemoryMax'] => Systemd::Unit::AmountOrPercent,
5959
Optional['MemoryLimit'] => Systemd::Unit::Amount,
60-
Optional['MemorySwapMax'] => Systemd::Unit::Amount,
60+
Optional['MemorySwapMax'] => Systemd::Unit::AmountOrPercent,
6161
Optional['TasksAccounting'] => Boolean,
6262
Optional['TasksMax'] => Systemd::Unit::AmountOrPercent,
6363
Optional['IOAccounting'] => Boolean,

0 commit comments

Comments
 (0)