Repository navigation
Conversation
|
...
Changing it this way would be a backward incompatible API change, for not much real gain. The various other components/interfaces are already inconsistent about this. For instance, CRI uses an int64 on the wire, and I think that's why we unfortunately ended up with an int64 for the function signature, and converting it to uint64. So I wouldn't break the API for this. Maybe simply ignore negative numbers (since we can't return an error) and document it. |
The CPU period is semantically unsigned: the kernel accepts cfs_period_us values in the range [1000, 1000000] (and the cgroup v2 cpu.max $PERIOD counterpart has the same range). The setter's int64 signature dates back to CRI using int64 on the wire. Combined with the UInt64() wrapper it silently converted negative values into garbage 64-bit values (e.g. -1 becoming 18446744073709551615), which then failed container creation inside runc with an error that gives no hint about the plugin-side cause. Since the setter cannot return an error, ignore negative values instead of recording a broken value, and document the behavior. The API stays backward compatible. Add tests covering both the value round-trip and the ignored negative value for both ContainerUpdate and ContainerAdjustment. Signed-off-by: pandaWall <mangosteen922@126.com>
d8d78c8 to
0f9d2db
Compare
Well, that makes sense. I was testing the offline mixed mode function in my own environment. I mistakenly set the CPU period to a negative value. I have re-adjusted the new submission. I have changed the title to a more appropriate one. |
The CPU period (like the realtime period, whose setter already takes uint64) is semantically unsigned. The int64 signature combined with the UInt64() wrapper silently converted negative values into garbage 64-bit values (e.g. -1 becoming 18446744073709551615), which then failed container creation inside runc with errors that give no hint about the plugin-side cause.
Change both ContainerUpdate.SetLinuxCPUPeriod and
ContainerAdjustment.SetLinuxCPUPeriod to take a uint64 argument. The setters have no in-repo callers outside tests, so no call sites need updating. Out-of-tree plugins calling these setters with a signed value will now fail to compile instead of producing a broken adjustment at runtime, which is the desired failure mode.
Add a test covering the value round-trip through both setters.