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

Manage ulimit with systemd::dropin_file and allow it to be unmanaged #391

Closed
wants to merge 4 commits into from
Closed

Manage ulimit with systemd::dropin_file and allow it to be unmanaged #391

wants to merge 4 commits into from

Conversation

laugmanuel
Copy link
Contributor

@laugmanuel laugmanuel commented Feb 22, 2021

This PR changes two things:

Fixes #390

Note: I can split this PR into two/three PRs if desired (or squash the commits together).

@laugmanuel laugmanuel changed the title 390 systemd dropin Manage ulimit with systemd::dropin_file and allow it to be unmanaged Feb 22, 2021
@laugmanuel
Copy link
Contributor Author

Test failures seem to be unrelated...

Copy link
Member

@ekohl ekohl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps this should also be modified to use systemd::unit_file:

file { "/etc/systemd/system/${service_name}.service":
ensure => file,
owner => 'root',
group => 'root',
mode => '0644',
content => template('redis/service_templates/redis.service.erb'),
}

https://github.com/voxpupuli/puppet-redis#soft-dependency also needs an update if systemd becomes a hard dependency.

manifests/init.pp Show resolved Hide resolved
manifests/ulimit.pp Outdated Show resolved Hide resolved
manifests/ulimit.pp Outdated Show resolved Hide resolved
manifests/instance.pp Show resolved Hide resolved
manifests/init.pp Outdated Show resolved Hide resolved
if versioncmp($facts['puppetversion'],'6.1.0') < 0 {
include systemd::systemctl::daemon_reload
Augeas['Systemd redis ulimit'] ~> Class['systemd::systemctl::daemon_reload']
ensure => absent,
}
Copy link
Member

@ekohl ekohl Feb 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no daemon reload code for Puppet < 6.1.0 in systemd::service_limits. Interestingly, in combination with restart_service that appears to be a bug.

Edit: to be clear, I don't think you should set $restart_service to true, but it should deal with daemon reloads. Or we should drop Puppet < 6.1.0.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The daemon reload is contained in systemd::dropin_file which is invoked indirectly by systemd::service_limits. As this PR would use the new way of defining the limits regardless of Puppet version, the reload should be handled there.

README.md Outdated Show resolved Hide resolved
@@ -309,8 +313,8 @@
}

if $manage_service_file {
file { "/etc/systemd/system/${service_name}.service":
ensure => file,
systemd::unit_file { "${service_name}.service":
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you pass enable and active as well, the unit file can manage the service and also properly apply daemon_reload. This is particularly important now that camptocamp/systemd has dropped the daemon_reload class in master.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See 58aa20c for what I think is roughly needed.

Comment on lines 37 to +38
file { "/etc/systemd/system/${redis::service_name}.service.d/limit.conf":
ensure => file,
owner => 'root',
group => 'root',
mode => '0444',
}
augeas { 'Systemd redis ulimit' :
incl => "/etc/systemd/system/${redis::service_name}.service.d/limit.conf",
lens => 'Systemd.lns',
changes => [
"defnode nofile Service/LimitNOFILE \"\"",
"set \$nofile/value \"${redis::ulimit}\"",
],
}
# Only necessary for Puppet < 6.1.0,
# See https://github.com/puppetlabs/puppet/commit/f8d5c60ddb130c6429ff12736bfdb4ae669a9fd4
if versioncmp($facts['puppetversion'],'6.1.0') < 0 {
include systemd::systemctl::daemon_reload
Augeas['Systemd redis ulimit'] ~> Class['systemd::systemctl::daemon_reload']
ensure => absent,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking more about this, it's a bit dubious how this should be handled. Previously it was an augeas lens which means it did manage one entry but users were free to manage other entries via other means.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea was that there is no duplicate of old and new settings. But you are right; if users added their custom limits, they should not get removed.
We could switch the augeas lens to exclude the the NoFile line or just stop managing the file at all (which will result in duplicates of NOFile)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or we just stick to using the current approach and I'll drop switching to puppet-systemd from this PR.

Copy link
Member

@ekohl ekohl Mar 30, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't mind doing a major version bump for it and making it clear that this is the behavior. Could use a comment perhaps?

manifests/instance.pp Outdated Show resolved Hide resolved
owner => 'root',
group => 'root',
selinux_ignore_defaults => true,
systemd::service_limits { "${redis::service_name}.service":
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about moving it into instance.pp? 2c2a322

Co-authored-by: Ewoud Kohl van Wijngaarden <[email protected]>
@laugmanuel
Copy link
Contributor Author

@ekohl, currently I'm a little bit hesitant as I can't quite overlook the changes/impact and get a full picture. WDYT about closing this PR in favour of new ones based on your commits (2c2a322 and 58aa20c)?

@ekohl
Copy link
Member

ekohl commented Apr 14, 2021

I would be OK with that.

@ekohl
Copy link
Member

ekohl commented Apr 19, 2021

I opened #396

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make ulimit optional or use puppet-systemd for dropin
2 participants