RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1351415 - [RFE] Unable to set soft and hard limits for services under systemd
Summary: [RFE] Unable to set soft and hard limits for services under systemd
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: systemd
Version: 7.2
Hardware: x86_64
OS: Linux
unspecified
high
Target Milestone: rc
: ---
Assignee: systemd-maint
QA Contact: Branislav Blaškovič
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-06-30 04:02 UTC by Jayaraj
Modified: 2022-01-21 15:38 UTC (History)
9 users (show)

Fixed In Version: systemd-219-23.el7
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-11-04 00:55:22 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2016:2216 0 normal SHIPPED_LIVE systemd bug fix and enhancement update 2016-11-03 13:24:51 UTC

Description Jayaraj 2016-06-30 04:02:48 UTC
Description of problem:

This is for TAM customer. The customer is in the middle of migrating 20 servers to RHEL 7 and want to configure their custom services under systemd. They are unable to set different values of soft and hard limit under systemd.
The setup works perfectly as defined in https://access.redhat.com/solutions/1346533. but the steps given in the above kcs set the soft and hard limit to same value. 


Version-Release number of selected component (if applicable):
RHEL 7.2 (3.10.0-327.10.1.el7.x86_64 )

How reproducible:
100%

Steps to Reproduce:
# mkdir /etc/systemd/system/httpd.service.d
# echo [Service] >/etc/systemd/system/httpd.service.d/ulimit.conf
# echo LimitNOFILE=8000 >>/etc/systemd/system/httpd.service.d/ulimit.conf
# echo LimitNPROC=32000 >>/etc/systemd/system/httpd.service.d/ulimit.conf
# cat /etc/systemd/system/httpd.service.d/ulimit.conf
[Service]
LimitNOFILE=8000
LimitNPROC=32000
# systemctl daemon-reload
# systemctl restart httpd
# systemctl show httpd | grep -ie nproc -e nofile
LimitNOFILE=8000
LimitNPROC=32000
# eval $(systemctl show httpd -p MainPID)
# egrep 'process|open files' /proc/$MainPID/limits
Limit                     Soft Limit           Hard Limit           Units   
Max processes             32000                32000                processes
Max open files            8000                 8000                 files

The above output shows same value for soft and hard limit. Unable to set the soft and hard limits to different values. 


Actual results:

Tried declaring the values to soft:hard in /etc/systemd/system/httpd.service.d/ulimit.conf like below but it is not getting applied and service is taking default values.
[Service]
LimitNOFILE=10240:20240
LimitNPROC=16000

Expected results:
The soft and hard limit should be of different values that are declared in /etc/systemd/system/httpd.service.d/ulimit.conf

Additional info:
Since daemons started by systemd don't employ pam login session, the limits can be set only in the service unit file. so no point of having limits defined in /etc/security/limits.conf

Comment 3 Michal Sekletar 2016-07-04 16:46:01 UTC
Already implemented upstream. We need to backport https://github.com/systemd/systemd/pull/1994 and follow-up fix-up commits.

Comment 8 Lukáš Nykrýn 2016-07-12 12:53:29 UTC
patches pushed to staging ->
core: dump rlim_cur too
https://github.com/lnykryn/systemd-rhel/commit/0c4a515

core: fix rlimit parsing
https://github.com/lnykryn/systemd-rhel/commit/b53ec8d

core: support <soft:hard> ranges for RLIMIT options
https://github.com/lnykryn/systemd-rhel/commit/81a95ec

time-util: add parse_time(), which is like parse_sec() but allows specification of default time unit if none is specified
https://github.com/lnykryn/systemd-rhel/commit/8afe425

core: accept time units for time-based resource limits
https://github.com/lnykryn/systemd-rhel/commit/128ef85

core: support IEC suffixes for RLIMIT stuff
https://github.com/lnykryn/systemd-rhel/commit/99074ee
-> post

Comment 10 Branislav Blaškovič 2016-07-28 09:03:47 UTC
Patches look sane but I am not sure how it should behave in case an admin sets incorrect limits, for example:

LimitNPROC=32000:30000 # so soft limit is greater than the hard one

Any ideas? Now it just totally ignores this line.

Comment 11 Branislav Blaškovič 2016-07-28 09:07:24 UTC
Ignoring incorrect values (for now), this bug looks fixed.

Using /CoreOS/systemd/Regression/Unable-to-set-soft-and-hard-limits-for-services

:: [   LOG    ] :: Package versions:
:: [   LOG    ] ::   systemd-219-24.el7.x86_64
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: [   LOG    ] :: Correct limits setup
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:: [   PASS   ] :: Command 'echo [Service] >/etc/systemd/system/httpd.service.d/ulimit.conf' (Expected 0, got 0)
:: [   PASS   ] :: Command 'echo LimitNOFILE=6000:8000 >>/etc/systemd/system/httpd.service.d/ulimit.conf' (Expected 0, got 0)
:: [   PASS   ] :: Command 'echo LimitNPROC=30000:32000 >>/etc/systemd/system/httpd.service.d/ulimit.conf' (Expected 0, got 0)
:: [   PASS   ] :: Command 'systemctl daemon-reload' (Expected 0, got 0)
:: [   LOG    ] :: rlServiceStart: Service httpd started successfully
:: [   LOG    ] :: Duration: 1s
:: [   LOG    ] :: Assertions: 4 good, 0 bad
:: [   PASS   ] :: RESULT: Correct limits setup

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: [   LOG    ] :: Correct limits test
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:: [   PASS   ] :: Command 'systemctl show httpd | grep -ie nproc -e nofile' (Expected 0, got 0)
:: [   PASS   ] :: Command 'cat /proc/8632/limits' (Expected 0, got 0)
:: [   PASS   ] :: Command 'grep "Max processes[ ]\+30000[ ]\+32000[ ]\+processes" /var/tmp/tmp.35rGIpMudS' (Expected 0, got 0)
:: [   PASS   ] :: Command 'grep "Max open files[ ]\+6000[ ]\+8000[ ]\+files" /var/tmp/tmp.35rGIpMudS' (Expected 0, got 0)
:: [   LOG    ] :: Duration: 0s
:: [   LOG    ] :: Assertions: 4 good, 0 bad
:: [   PASS   ] :: RESULT: Correct limits test

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: [   LOG    ] :: Equal limit setup
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:: [   PASS   ] :: Command 'echo > /etc/systemd/system/httpd.service.d/ulimit.conf' (Expected 0, got 0)
:: [   PASS   ] :: Command 'echo [Service] >/etc/systemd/system/httpd.service.d/ulimit.conf' (Expected 0, got 0)
:: [   PASS   ] :: Command 'echo LimitNOFILE=8000:8000 >>/etc/systemd/system/httpd.service.d/ulimit.conf' (Expected 0, got 0)
:: [   PASS   ] :: Command 'echo LimitNPROC=32000:32000 >>/etc/systemd/system/httpd.service.d/ulimit.conf' (Expected 0, got 0)
:: [   PASS   ] :: Command 'systemctl daemon-reload' (Expected 0, got 0)
:: [   LOG    ] :: rlServiceStart: Service httpd already running, stopping first.
:: [   LOG    ] :: rlServiceStart: Service httpd started successfully
:: [   LOG    ] :: Duration: 2s
:: [   LOG    ] :: Assertions: 5 good, 0 bad
:: [   PASS   ] :: RESULT: Equal limit setup

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: [   LOG    ] :: Equal limits test
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:: [   PASS   ] :: Command 'systemctl show httpd | grep -ie nproc -e nofile' (Expected 0, got 0)
:: [   PASS   ] :: Command 'cat /proc/8852/limits' (Expected 0, got 0)
:: [   PASS   ] :: Command 'grep "Max processes[ ]\+32000[ ]\+32000[ ]\+processes" /var/tmp/tmp.8LjxkmRJzM' (Expected 0, got 0)
:: [   PASS   ] :: Command 'grep "Max open files[ ]\+8000[ ]\+8000[ ]\+files" /var/tmp/tmp.8LjxkmRJzM' (Expected 0, got 0)
:: [   LOG    ] :: Duration: 0s
:: [   LOG    ] :: Assertions: 4 good, 0 bad
:: [   PASS   ] :: RESULT: Equal limits test


Switching to verified.

Comment 15 errata-xmlrpc 2016-11-04 00:55:22 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHBA-2016-2216.html

Comment 18 Plumber Bot 2022-01-21 15:38:21 UTC
Dropping the stale needinfo. If our input is still needed, please set the needinfo again.


Note You need to log in before you can comment on or make changes to this bug.