3 ms·
If by "CPU mask" you refer to the `sched_getaffinity` syscall, I can't reproduce this behavior. What I tried: I created a "Burstable" Pod and run `nproc` [0] o
by n3t 3y ago
If by "CPU mask" you refer to the `sched_getaffinity` syscall, I can't reproduce this behavior.
What I tried: I created a "Burstable" Pod and run `nproc` [0] on it. It returned N CPUs (N > 1).
Then I created a "Guaranteed QoS" Pod with both requests and limit set to 1 CPU. `nproc` returned N CPUs on it.
I went back to the "Burstable" Pod. It returned N.
I created a fresh "Burstable" Pod and run `nproc` on it, got N again. Please note that the "Guaranteed QoS" Pod is still running.
> Pods with Guaranteed QoS will have exactly the number of CPUs they asked for, no more or less
Well, in my case I asked for 1 CPU and got more, i.e. N CPUs.
Also, please note that Pods might ask for fractional CPUs.
[0]: coreutils `nproc` program uses `sched_getaffinity` syscall under the hood, at least on my system. I've just checked it with `strace` to be sure.
- jeffbee 3y agoI don't know what nproc does. Consider `taskset`
- n3t 3y agoI re-did the experiment again with `taskset` and got the same results, i.e. the mask is independent of creation of the "Guaranteed QoS" Pod. FWIW, `taskset` uses the same syscall as `nproc` (according to `strace`).
- jeffbee 3y agoPerhaps it is an artifact of your and my various container runtimes. For me, in a guaranteed qos pod, taskset shows just 1 visible CPU for a Guaranteed QoS pod with limit=request=1. # taskset -c -p 1 pid 1's current affinity list: 1 # nproc 1 I honestly do not see how it can work otherwise.
- n3t 3y agoAfter reading https://kubernetes.io/docs/tasks/administer-cluster/cpu-management-policies/#cpu-management-policies https://kubernetes.io/docs/tasks/administer-cluster/cpu-mana..., I think we have different policies set for the CPU Manager. In my case it's `"cpuManagerPolicy": "none"` and I suppose you're using `"static"` policy. Well, TIL. Thanks!
- jeffbee 3y agoTIL also. The difference between guaranteed and burstable seems meaningless without this setting.