skip set cpu.weight when cpu.idle is enabled in cgroups v2
In cgroups v2, setting cpu.weight when cpu.idle==1 will fail with Invalid argument
This pr fixed this situation, consistent with https://github.com/opencontainers/runc/blob/main/libcontainer/cgroups/systemd/v2.go#L119
Instead of silently skipping we should fail as a validation error.
Instead of silently skipping we should fail as a validation error.
@mrunalp Thanks for reply.
I'm still a little confused about the idle parameter.
There is no description in the spec that shares and idle cannot be applied at the same time. But If I set both shares and idle, systemd driver and fs2 driver will behave differently.
| system\driver | systemd/v2 | fs2/cpu |
|---|---|---|
| support idle & systemd < 252 | systemd:set cpu.weight=1 fsMgr:set cpu.idle=1 & return error |
set cpu.idle=1 & return error |
| support idle & systemd > 252 | systemd:set cpu.idle=1 fsMgr:set cpu.idle=1 & return error |
set cpu.idle=1 & return error |
| not support idle | return error | return error |
So I think fs2 should be compatible with this situation like systemd, or directly add a hint in the document that they cannot be used at the same time?
Instead of silently skipping we should fail as a validation error.
Should be a warning to avoid breaking compatibility?
Yes, this should probably be a warning. I'm going to carry this into #4227.
There's no need for a warning. The problem is, Set is called during runc update with a combination of old and new settings, and thus it's normal for cpuweight and cpuidle both being set.
This PR needs a test case though. Can you add one @qdaxb ?