I have been trying to set up resource controls on 22.04.1 login node so users can't degrade the system by running anything too intensive. I looked at using cgroups
but apparently since it's a systemd system, user-.slice
is what I'm after. Unfortunately I can't even get the default service to launch.
❯ sudo systemctl status user-.slice
Warning: The unit file, source configuration file or drop-ins of user-.slice changed on disk. Run 'systemctl daemon-reload' to reload units.
○ user-.slice - User Slice of UID
Loaded: error (Reason: Unit user-.slice failed to load properly, please adjust/correct and reload service manager: Invalid argument)
Drop-In: /usr/lib/systemd/system/user-.slice.d
└─10-defaults.conf
Active: inactive (dead)
Docs: man:user@.service(5)
I can't see what argument is invalid and I have reloaded the units with sudo systemctl daemon-reload
but it still says they've change...
❯ sudo systemctl daemon-reload
❯ sudo systemctl restart user-.slice
Failed to start user-.slice: Unit user-.slice failed to load properly, please adjust/correct and reload service manager: Invalid argument
See system logs and 'systemctl status user-.slice' for details.
❯ systemctl status user-.slice
Warning: The unit file, source configuration file or drop-ins of user-.slice changed on disk. Run 'systemctl daemon-reload' to reload units.
○ user-.slice - User Slice of UID
Loaded: error (Reason: Unit user-.slice failed to load properly, please adjust/correct and reload service manager: Invalid argument)
Drop-In: /usr/lib/systemd/system/user-.slice.d
└─10-defaults.conf
Active: inactive (dead)
Docs: man:user@.service(5)
The main configs are currently the defaults:
❯ cat /usr/lib/systemd/system/user.slice
# SPDX-License-Identifier: LGPL-2.1-or-later
#
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
[Unit]
Description=User and Session Slice
Documentation=man:systemd.special(7)
Before=slices.target
❯ cat /usr/lib/systemd/system/user-.slice.d/10-defaults.conf
# SPDX-License-Identifier: LGPL-2.1-or-later
#
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
[Unit]
Description=User Slice of UID %j
Documentation=man:user@.service(5)
After=systemd-user-sessions.service
StopWhenUnneeded=yes
[Slice]
TasksMax=33%
Ultimately I just want to add 2 settings for memory and cpu caps:
❯ cat 50-user-caps.conf
[Slice]
CPUQuota=400%
MemoryMax=4G
Any clue what's going on?
Answered by @steeldriver
You don't interact with the user-.slice
service, but the user-UID.slice
ones that automatically pick up the drop ins.