Add I/O limit support to resource limits

- Pass --io parameter to lscgctl with bytes/sec value
- Convert ioLimitMBPS from MB/s to bytes/s for lscgctl
- Update log message to include I/O limit information
- Add note about systemd io controller delegation requirement
This commit is contained in:
usmannasir 2025-11-12 23:43:59 +05:00
parent 32b55993c5
commit 888a7e0552
1 changed files with 8 additions and 4 deletions

View File

@ -343,21 +343,25 @@ class ResourceLimitsManager:
# Tasks: use procHardLimit as max tasks # Tasks: use procHardLimit as max tasks
max_tasks = package.procHardLimit max_tasks = package.procHardLimit
# I/O: convert MB/s to bytes/s (lscgctl expects bytes/sec)
io_limit_bytes = package.ioLimitMBPS * 1024 * 1024
# Build lscgctl command # Build lscgctl command
# Format: lscgctl set username --cpu 100 --mem 1024M --tasks 500 # Format: lscgctl set username --cpu 100 --mem 1024M --io 10485760 --tasks 500
cmd = [ cmd = [
self.LSCGCTL_PATH, self.LSCGCTL_PATH,
'set', 'set',
username, username,
'--cpu', str(cpu_percent), '--cpu', str(cpu_percent),
'--mem', memory_limit, '--mem', memory_limit,
'--io', str(io_limit_bytes),
'--tasks', str(max_tasks) '--tasks', str(max_tasks)
] ]
# Note: I/O limits may require additional configuration # Note: I/O limits are configured but may not be enforced at kernel level
# Check if lscgctl supports --io parameter # without systemd io controller delegation to user slices
logging.writeToFile(f"Setting limits for user {username}: CPU={cpu_percent}%, MEM={memory_limit}, TASKS={max_tasks}") logging.writeToFile(f"Setting limits for user {username}: CPU={cpu_percent}%, MEM={memory_limit}, I/O={package.ioLimitMBPS}MB/s, TASKS={max_tasks}")
result = subprocess.run( result = subprocess.run(
cmd, cmd,