-
Notifications
You must be signed in to change notification settings - Fork 956
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cpu fullload's --cpu-percent flag doesn't work in OCI runtime #1079
Comments
问题描述类型: bug report 问题描述使用 预期行为当指定 CPU 负载百分比(例如 50%)时,目标 Pod 的 CPU 使用率应反映指定的百分比。例如,如果 Pod 的 CPU 限制为 1 核心且 CPU 负载百分比设置为 50%,则 CPU 使用率应约为 50%。 复现步骤(尽量简洁和精确)
环境信息
其他需要了解的信息问题出现的原因是 为了解决这个问题,工具应该正确确定目标 Pod 的 CPU 限制,并使用该值来计算 CPU 负载。CPU 限制可以从 Pod 的 cgroup 配置中获取。 此外,以下问题已被报告并与此问题相关:
详细分析与解决方案使用 cgroups 信息来确定目标 Pod 的 CPU 限制。 CPU 限制可以从 cgroup 文件 |
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:
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: