You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using the chaosblade tool to simulate CPU load in a Kubernetes Pod, specifying the CPU load percentage (range 0-100, default 100) has no effect. The CPU usage always reaches 100%, regardless of the specified rate.
Describe what you expected to happen
When specifying a CPU load percentage (e.g., 50%), the CPU usage of the target Pod should reflect the specified percentage. For example, if the CPU limit of the Pod is 1 core and the CPU load percentage is set to 50%, the CPU usage should be around 50%.
How to reproduce it (as minimally and precisely as possible)
The issue arises because the chaosblade tool incorrectly sets the number of CPU cores to the total number of cores available on the host machine (runtime.NumCPU()). This leads to the CPU load being calculated based on the total host CPU cores, which often exceeds the CPU limit of the target Pod.
To resolve this issue, the tool should correctly determine the CPU limit of the target Pod and use that value to calculate the CPU load. The CPU limit can be obtained from the cgroup configuration of the Pod.
Additionally, the following issues have been reported and are related to this problem:
Use the cgroups information to determine the CPU limit of the target Pod.
The CPU limit can be obtained from the cgroup files /sys/fs/cgroup/cpu/${pod-container-cgroup-dir}/cpu.cfs_quota_us and /sys/fs/cgroup/cpu/${pod-container-cgroup-dir}/cpu.cfs_period_us.
In the privileged chaosblade-tool daemonset pod, the host's /sys is mounted to /host-sys. Therefore, the correct path to the cgroup files would be /host-sys/fs/cgroup/cpu/${pod-container-cgroup-dir}/cpu.cfs_quota_us and /host-sys/fs/cgroup/cpu/${pod-container-cgroup-dir}/cpu.cfs_period_us.
The text was updated successfully, but these errors were encountered:
Issue Description
Type: bug report
Describe what happened (or what feature you want)
When using the chaosblade tool to simulate CPU load in a Kubernetes Pod, specifying the CPU load percentage (range 0-100, default 100) has no effect. The CPU usage always reaches 100%, regardless of the specified rate.
Describe what you expected to happen
When specifying a CPU load percentage (e.g., 50%), the CPU usage of the target Pod should reflect the specified percentage. For example, if the CPU limit of the Pod is 1 core and the CPU load percentage is set to 50%, the CPU usage should be around 50%.
How to reproduce it (as minimally and precisely as possible)
Tell us your environment
Anything else we need to know?
The issue arises because the chaosblade tool incorrectly sets the number of CPU cores to the total number of cores available on the host machine
(runtime.NumCPU())
. This leads to the CPU load being calculated based on the total host CPU cores, which often exceeds the CPU limit of the target Pod.To resolve this issue, the tool should correctly determine the CPU limit of the target Pod and use that value to calculate the CPU load. The CPU limit can be obtained from the cgroup configuration of the Pod.
Additionally, the following issues have been reported and are related to this problem:
chaosblade-operator/issues/102
chaosblade/issues/463
chaosblade/issues/805
chaosblade/issues/928
chaosblade/issues/801
Detailed Analysis and Solution
Use the cgroups information to determine the CPU limit of the target Pod.
The CPU limit can be obtained from the cgroup files
/sys/fs/cgroup/cpu/${pod-container-cgroup-dir}/cpu.cfs_quota_us
and/sys/fs/cgroup/cpu/${pod-container-cgroup-dir}/cpu.cfs_period_us
.In the privileged chaosblade-tool daemonset pod, the host's
/sys
is mounted to/host-sys
. Therefore, the correct path to the cgroup files would be/host-sys/fs/cgroup/cpu/${pod-container-cgroup-dir}/cpu.cfs_quota_us
and/host-sys/fs/cgroup/cpu/${pod-container-cgroup-dir}/cpu.cfs_period_us
.The text was updated successfully, but these errors were encountered: