Skip to content

Commit 07c9432

Browse files
committed
Deprecate systemd::service_limits
The `systemd::service_limts` and corresponding type `Systemd::Servicelimits` is deprecated. Switch to `systemd::dropin_file` for a source attributed `systemd::service_limits` or `systemd::manage_unit` for a `limits` attributed `systemd::service_limits`.
1 parent 63a41e0 commit 07c9432

File tree

4 files changed

+51
-15
lines changed

4 files changed

+51
-15
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,11 @@ Finished on controller-0:
586586
}
587587
```
588588

589+
## Deprecation Notices
590+
591+
The type `systemd::service_limits` is deprecated and `systemd::manage_dropin` or `systemd::dropin_file` can
592+
be used instead.
593+
589594
## Transfer Notice
590595

591596
This plugin was originally authored by [Camptocamp](http://www.camptocamp.com).

REFERENCE.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
* [`systemd::manage_unit`](#systemd--manage_unit): Generate unit file from template
3535
* [`systemd::modules_load`](#systemd--modules_load): Creates a modules-load.d drop file
3636
* [`systemd::network`](#systemd--network): Creates network config for systemd-networkd
37-
* [`systemd::service_limits`](#systemd--service_limits): Adds a set of custom limits to the service
37+
* [`systemd::service_limits`](#systemd--service_limits): Deprecated - Adds a set of custom limits to the service
3838
* [`systemd::timer`](#systemd--timer): Create a timer and optionally a service unit to execute with the timer unit
3939
* [`systemd::timer_wrapper`](#systemd--timer_wrapper): Helper to define timer and accompanying services for a given task (cron like interface).
4040
* [`systemd::tmpfile`](#systemd--tmpfile): Creates a systemd tmpfile
@@ -60,7 +60,7 @@
6060
* [`Systemd::LogindSettings::Ensure`](#Systemd--LogindSettings--Ensure): defines allowed ensure states for systemd-logind settings
6161
* [`Systemd::MachineInfoSettings`](#Systemd--MachineInfoSettings): Matches Systemd machine-info (hostnamectl) file Struct
6262
* [`Systemd::OomdSettings`](#Systemd--OomdSettings): Configurations for oomd.conf
63-
* [`Systemd::ServiceLimits`](#Systemd--ServiceLimits): Matches Systemd Service Limit Struct
63+
* [`Systemd::ServiceLimits`](#Systemd--ServiceLimits): Deprecated - Matches Systemd Service Limit Struct
6464
* [`Systemd::Unit`](#Systemd--Unit): custom datatype that validates different filenames for systemd units and unit templates
6565
* [`Systemd::Unit::Amount`](#Systemd--Unit--Amount): Systemd definition of amount, often bytes or united bytes
6666
* [`Systemd::Unit::AmountOrPercent`](#Systemd--Unit--AmountOrPercent): Systemd definition of amount, often bytes or united bytes
@@ -1534,7 +1534,7 @@ Default value: `true`
15341534

15351535
### <a name="systemd--service_limits"></a>`systemd::service_limits`
15361536

1537-
Adds a set of custom limits to the service
1537+
Deprecated - Adds a set of custom limits to the service
15381538

15391539
* **See also**
15401540
* systemd.exec(5)
@@ -2502,7 +2502,7 @@ Struct[{
25022502

25032503
### <a name="Systemd--ServiceLimits"></a>`Systemd::ServiceLimits`
25042504

2505-
Matches Systemd Service Limit Struct
2505+
Deprecated - Matches Systemd Service Limit Struct
25062506

25072507
Alias of
25082508

manifests/service_limits.pp

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Adds a set of custom limits to the service
1+
# Deprecated - Adds a set of custom limits to the service
22
#
33
# @api public
44
#
@@ -63,14 +63,44 @@
6363
}
6464
}
6565

66-
systemd::dropin_file { "${name}-90-limits.conf":
67-
ensure => $ensure,
68-
unit => $name,
69-
filename => '90-limits.conf',
70-
path => $path,
71-
selinux_ignore_defaults => $selinux_ignore_defaults,
72-
content => $_content,
73-
source => $source,
74-
notify_service => true,
66+
if $limits {
67+
# Some typing changed between Systemd::ServiceLimits and Systemd::Unit::Service
68+
$_now_tupled = [
69+
'IODeviceWeight',
70+
'IOReadBandwidthMax',
71+
'IOWriteBandwidthMax',
72+
'IOReadIOPSMax',
73+
'IOWriteIOPSMax',
74+
]
75+
76+
$_my_limits = $limits.map | $_directive, $_value | {
77+
if $_directive in $_now_tupled {
78+
{ $_directive => $_value.map | $_pair | { Array($_pair).flatten } } # Convert { 'a' => 'b' } to ['a', b']
79+
} else {
80+
{ $_directive => $_value }
81+
}
82+
}.reduce | $_memo, $_value | { $_memo + $_value }
83+
84+
deprecation("systemd::servicelimits - ${title}",'systemd::servicelimits is deprecated, use systemd::manage_dropin')
85+
systemd::manage_dropin { '#{name}-90-limits.conf':
86+
ensure => $ensure,
87+
unit => $name,
88+
filename => '90-limits.conf',
89+
path => $path,
90+
selinux_ignore_defaults => $selinux_ignore_defaults,
91+
service_entry => $_my_limits,
92+
notify_service => true,
93+
}
94+
} else {
95+
deprecation("systemd::servicelimits ${title}",'systemd::servicelimits is deprecated, use systemd::dropin_file or systemd::manage_dropin')
96+
systemd::dropin_file { '#{name}-90-limits.conf':
97+
ensure => $ensure,
98+
unit => $name,
99+
filename => '90-limits.conf',
100+
path => $path,
101+
selinux_ignore_defaults => $selinux_ignore_defaults,
102+
source => $source,
103+
notify_service => true,
104+
}
75105
}
76106
}

types/servicelimits.pp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# Matches Systemd Service Limit Struct
1+
# @summary Deprecated - Matches Systemd Service Limit Struct
2+
#
23
type Systemd::ServiceLimits = Struct[
34
{
45
Optional['LimitCPU'] => Pattern['^\d+(s|m|h|d|w|M|y)?(:\d+(s|m|h|d|w|M|y)?)?$'],

0 commit comments

Comments
 (0)