Skip to content

Commit cb87ddd

Browse files
committed
Allow OOMScoreAdjust within Mount, Socket, Swap Units
Allow OOMScoreAdjust to be added to `[Mount]`, `[Socket]` and `[Swap]` unit sections. e.g. ```puppet systemd::manage_dropin{ 'nokill.conf': ensure => present, unit => 'home.mount', mount_entry => { 'OOMScoreAdjust' => -1000, }, } ``` * https://www.freedesktop.org/software/systemd/man/latest/systemd.exec.html#Description
1 parent 2d3efe2 commit cb87ddd

File tree

7 files changed

+61
-28
lines changed

7 files changed

+61
-28
lines changed

REFERENCE.md

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3186,16 +3186,17 @@ Alias of
31863186

31873187
```puppet
31883188
Struct[{
3189-
Optional['What'] => String[1],
3190-
Optional['Where'] => Stdlib::Unixpath,
3191-
Optional['Type'] => String[1],
3192-
Optional['Options'] => String[1],
3193-
Optional['SloppyOptions'] => Boolean,
3194-
Optional['LazyUnmount'] => Boolean,
3195-
Optional['ReadWriteOnly'] => Boolean,
3196-
Optional['ForceUnmount'] => Boolean,
3197-
Optional['DirectoryMode'] => Stdlib::Filemode,
3198-
Optional['TimeoutSec'] => String[0],
3189+
Optional['What'] => String[1],
3190+
Optional['Where'] => Stdlib::Unixpath,
3191+
Optional['Type'] => String[1],
3192+
Optional['Options'] => String[1],
3193+
Optional['SloppyOptions'] => Boolean,
3194+
Optional['LazyUnmount'] => Boolean,
3195+
Optional['ReadWriteOnly'] => Boolean,
3196+
Optional['ForceUnmount'] => Boolean,
3197+
Optional['DirectoryMode'] => Stdlib::Filemode,
3198+
Optional['TimeoutSec'] => String[0],
3199+
Optional['OOMScoreAdjust'] => Integer[-1000,1000],
31993200
}]
32003201
```
32013202

@@ -3504,6 +3505,7 @@ Struct[{
35043505
Optional['FileDescriptorName'] => String[1,255],
35053506
Optional['TriggerLimitIntervalSec'] => String[1],
35063507
Optional['TriggerLimitBurst'] => Integer[0],
3508+
Optional['OOMScoreAdjust'] => Integer[-1000,1000],
35073509
}]
35083510
```
35093511

@@ -3518,10 +3520,11 @@ Alias of
35183520

35193521
```puppet
35203522
Struct[{
3521-
Optional['What'] => String[1],
3522-
Optional['Options'] => String[1],
3523-
Optional['Priority'] => Integer,
3524-
Optional['TimeoutSec'] => Variant[Integer[0],String[0]]
3523+
Optional['What'] => String[1],
3524+
Optional['Options'] => String[1],
3525+
Optional['Priority'] => Integer,
3526+
Optional['TimeoutSec'] => Variant[Integer[0],String[0]],
3527+
Optional['OOMScoreAdjust'] => Integer[-1000,1000],
35253528
}]
35263529
```
35273530

spec/type_aliases/systemd_unit_mount_spec.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,13 @@
3939
it { is_expected.to allow_value({ assert => true }) }
4040
end
4141
end
42+
43+
context 'with a key of OOMScoreAdjust' do
44+
it {
45+
is_expected.to allow_value({ 'OOMScoreAdjust' => 999 })
46+
is_expected.to allow_value({ 'OOMScoreAdjust' => -999 })
47+
is_expected.not_to allow_value({ 'OOMScoreAdjust' => 1005 })
48+
is_expected.not_to allow_value({ 'OOMScoreAdjust' => '10' })
49+
}
50+
end
4251
end

spec/type_aliases/systemd_unit_socket_spec.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,13 @@
1717
it { is_expected.not_to allow_value({ assert => 'mything' }) }
1818
end
1919
end
20+
21+
context 'with a key of OOMScoreAdjust' do
22+
it {
23+
is_expected.to allow_value({ 'OOMScoreAdjust' => 999 })
24+
is_expected.to allow_value({ 'OOMScoreAdjust' => -999 })
25+
is_expected.not_to allow_value({ 'OOMScoreAdjust' => 1005 })
26+
is_expected.not_to allow_value({ 'OOMScoreAdjust' => '10' })
27+
}
28+
end
2029
end

spec/type_aliases/systemd_unit_swap_spec.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,13 @@
2525
context 'with a key of Where' do
2626
it { is_expected.not_to allow_value({ 'Where' => '/mnt/foo' }) }
2727
end
28+
29+
context 'with a key of OOMScoreAdjust' do
30+
it {
31+
is_expected.to allow_value({ 'OOMScoreAdjust' => 999 })
32+
is_expected.to allow_value({ 'OOMScoreAdjust' => -999 })
33+
is_expected.not_to allow_value({ 'OOMScoreAdjust' => 1005 })
34+
is_expected.not_to allow_value({ 'OOMScoreAdjust' => '10' })
35+
}
36+
end
2837
end

types/unit/mount.pp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,16 @@
33
#
44
type Systemd::Unit::Mount = Struct[
55
{
6-
Optional['What'] => String[1],
7-
Optional['Where'] => Stdlib::Unixpath,
8-
Optional['Type'] => String[1],
9-
Optional['Options'] => String[1],
10-
Optional['SloppyOptions'] => Boolean,
11-
Optional['LazyUnmount'] => Boolean,
12-
Optional['ReadWriteOnly'] => Boolean,
13-
Optional['ForceUnmount'] => Boolean,
14-
Optional['DirectoryMode'] => Stdlib::Filemode,
15-
Optional['TimeoutSec'] => String[0],
6+
Optional['What'] => String[1],
7+
Optional['Where'] => Stdlib::Unixpath,
8+
Optional['Type'] => String[1],
9+
Optional['Options'] => String[1],
10+
Optional['SloppyOptions'] => Boolean,
11+
Optional['LazyUnmount'] => Boolean,
12+
Optional['ReadWriteOnly'] => Boolean,
13+
Optional['ForceUnmount'] => Boolean,
14+
Optional['DirectoryMode'] => Stdlib::Filemode,
15+
Optional['TimeoutSec'] => String[0],
16+
Optional['OOMScoreAdjust'] => Integer[-1000,1000],
1617
}
1718
]

types/unit/socket.pp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,6 @@
6161
Optional['FileDescriptorName'] => String[1,255],
6262
Optional['TriggerLimitIntervalSec'] => String[1],
6363
Optional['TriggerLimitBurst'] => Integer[0],
64+
Optional['OOMScoreAdjust'] => Integer[-1000,1000],
6465
}
6566
]

types/unit/swap.pp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
#
44
type Systemd::Unit::Swap = Struct[
55
{
6-
Optional['What'] => String[1],
7-
Optional['Options'] => String[1],
8-
Optional['Priority'] => Integer,
9-
Optional['TimeoutSec'] => Variant[Integer[0],String[0]]
6+
Optional['What'] => String[1],
7+
Optional['Options'] => String[1],
8+
Optional['Priority'] => Integer,
9+
Optional['TimeoutSec'] => Variant[Integer[0],String[0]],
10+
Optional['OOMScoreAdjust'] => Integer[-1000,1000],
1011
}
1112
]

0 commit comments

Comments
 (0)