Skip to content

systemd unit ulimit bug #321

@brownc

Description

@brownc

Consider this snippet from a chef role:

chef_type:           role
default_attributes:
  redisio:
    default_settings:
      ulimit:                50000

When Chef converges, on a CentOS 7 system with systemd, you get the following in your systemd unit file:

[Unit]
Description=Redis persistent key-value database
After=network.target

[Service]
ExecStart=/usr/bin/redis-server /etc/redis/%i.conf --daemonize no
ExecStop=/usr/bin/redis-shutdown
User=redis
Group=redis
LimitNOFILE=10032

[Install]
WantedBy=multi-user.target

The two don't match.

Turns out there's a two fold problem:

  1. Commit 7146921 has put the systemd template file into recipes/configure.rb. This is illogical bearing in mind that all the init.d scripts/etc and other config is dont in providers/configure.rb.

  2. As a result of that, recipes/configure.rb can't make use of the "descriptors" variable that's calculated for the ulimit requirement that lives in providers/configure.rb. Instead it's using "maxclients+32" to calculate the ulimit, which is different to the method in the provider (and makes ulimit defunct for systemd systems)

I was going to pop in a new branch and a PR to move the systemd template into the provider and then use "descriptors" to manage the ulimit for systemd, however, there's a couple of other major systemd enhancements already outstanding with pull requests which will likely clash.

Let me know if you want the above fix done anyway. This is low priority anyway as some would probably argue why there's a need for such a differential.

In the meantime to workaround, set redisio/default_settings/maxclients attribute to what you want the ulimit to match to on systemd systems, and away you go.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions