Skip to content
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

chaosblade-operator1.7.2 pod cpu故障注入失败 #234

Open
wjsshide opened this issue Nov 22, 2023 · 3 comments
Open

chaosblade-operator1.7.2 pod cpu故障注入失败 #234

wjsshide opened this issue Nov 22, 2023 · 3 comments

Comments

@wjsshide
Copy link

描述: operator1.7.2注入pod的cpu故障的时候, 直接会把该pod下的容器cpu直接打满
debug发现获取runtime.NumCpu()获取的是宿主机的核数不是容器的cpu核数

yaml文件:
apiVersion: chaosblade.io/v1alpha1
kind: ChaosBlade
metadata:
name: cpu-pod-6
spec:
experiments:

  • scope: pod
    target: cpu
    action: fullload
    desc: "increase pod cpu load by names"
    matchers:
    • name: names
      value:
      • "nginx-6664874ddd-gqjhx"
    • name: cpu-percent
      value:
      • "60"
    • name: namespace
      value:
      • "nginx"
    • name: timeout
      value:
      • "60"
@binbin0325
Copy link
Member

binbin0325 commented Nov 23, 2023

pod 注入cpu负载本质就是对容器注入cpu负载,这没啥问题。
runtime.NumCpu()获取的是当前容器的cpu核心数,这里通过_ "go.uber.org/automaxprocs/maxprocs" 进行控制了

@wjsshide
Copy link
Author

pod 注入cpu负载本质就是对容器注入cpu负载,这没啥问题。 runtime.NumCpu()获取的是当前容器的cpu核心数,这里通过_ "go.uber.org/automaxprocs/maxprocs" 进行控制了

您好 我对pod注入cpu故障, cpu-percent是60%, pod的cpu limit是1000m, 正常来说 应该把容器cpu打满60%, 但是事实上打了100%, 我加log的 时候发现untime.NumCpu()获取的宿主机的核数,不是容器的核数,go.uber.org/automaxprocs/maxprocs 没生效

我把uber的方法显示在代码调用了一下,结果发现报错了,我理解是因为这个报错导致的cpu获取有问题, 报错信息如下
msg="failed to set GOMAXPROCS: path "/kubepods.slice/kubepods-pod3f8b57a9_829a_4d47_b220_b830da173956.slice/cri-containerd-2b7a54862ac13ec3bf45d691f6e900ba67b27ca3718dab124f6d04e1644ee53e.scope" is not a descendant of mount point root "/kubepods.slice/kubepods-besteffort.slice/kubepods-besteffort-pod497e810a_3a2e_49d6_a6a3_ca9b49062993.slice/cri-containerd-f3ee784b971d2e8e2bff1714496b5c813a9f6dc0e726530b004a4a1a01bc470e.scope" and cannot be exposed from "/sys/fs/cgroup/systemd"" location="/go/src/github.com/chaosblade-io/chaosblade/target/cache/chaosblade-exec-os/exec/cpu/cpu.go:180" uid=1c50e84360e9a90c

@spencercjh
Copy link
Contributor

pod 注入cpu负载本质就是对容器注入cpu负载,这没啥问题。 runtime.NumCpu()获取的是当前容器的cpu核心数,这里通过_ "go.uber.org/automaxprocs/maxprocs" 进行控制了

并不正确,automaxprocs/maxprocs 获取的是 daemonset pod 的 CPU 数量,详情可以看这个 issue:chaosblade-io/chaosblade#1079

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants