chaosblade icon indicating copy to clipboard operation
chaosblade copied to clipboard

if 'tc' not installed on system?

Open ntlzthm8 opened this issue 2 years ago • 6 comments

Issue Description

Type: feature request or question

Describe what happened (or what feature you want)

Using the chaosblade in kubernetes (with chaos-operator), some images do not have tc on board (such as openjdk:latest). NET_SCH_NETEM module is not installed in the Linux kernel. And then we get an error.

time="2022-03-09T10:09:35Z" level=info msg="Exec command in pod" command="[/tmp/chaosblade/blade create network delay  --offset=1000 --interface=eth0 --time=3000 --local-port=6379]" container=carts podName=carts-76dd6bf8f9-pmh9p podNamespace=sock-shop
time="2022-03-09T10:09:38Z" level=info msg="get err message" command="[/tmp/chaosblade/blade create network delay  --offset=1000 --interface=eth0 --time=3000 --local-port=6379]" container=carts err="{\"code\":52003,\"success\":false,\"error\":\"`tc`: command not found\",\"result\":\"ca980adee292db40\"}" out= podName=carts-76dd6bf8f9-pmh9p podNamespace=sock-shop
time="2022-03-09T10:09:38Z" level=error msg="`pods/exec`: k8s exec failed, err: {\"code\":52003,\"success\":false,\"error\":\"`tc`: command not found\",\"result\":\"ca980adee292db40\"}\n" location="github.com/chaosblade-io/chaosblade-operator/exec/model.(*ExecCommandInPodExecutor).execCommands.func1" uid=
time="2022-03-09T10:09:38Z" level=info msg="success: false, statuses: [{Id: State:Error Code:52003 Error:`tc`: command not found Success:false Kind:pod Identifier:sock-shop/minikube/carts-76dd6bf8f9-pmh9p/carts/bce96b6d27fb}]" experiment=b5dc4c2fbb1d15c8

Are there any practices? Pumba project use sidekick containers with tc on board.

ntlzthm8 avatar Mar 10 '22 09:03 ntlzthm8

Since version 1.4.0, you can use the use-sidecar-container-network parameter to solve this problem.

xcaspar avatar Mar 27 '22 07:03 xcaspar

Since version 1.4.0, you can use the use-sidecar-container-network parameter to solve this problem.

can you post any examples?

ntlzthm8 avatar Mar 28 '22 11:03 ntlzthm8

Like this:

./blade c k8s container-network delay --time 1000 --interface eth0 --names tomcat-7bb564644c-49ztz --container-names tomcat --namespace default --use-sidecar-container-network --kubeconfig ~/.kube/config

xcaspar avatar Mar 28 '22 12:03 xcaspar

The code url: https://github.com/chaosblade-io/chaosblade-operator/blob/4af4f676d2bb39b3d71275275761efbbe9e8e12d/exec/model/model.go#L197

xcaspar avatar Mar 28 '22 12:03 xcaspar

What if the tc command not found on the linux system? This is not for Kubernetes related, but bare metal. When i do the network delay or network loss, i get tc command not found. Will 1.4 version solve this issue as well?

JohnMatty avatar May 25 '22 16:05 JohnMatty

What if the tc command not found on the linux system? This is not for Kubernetes related, but bare metal. When i do the network delay or network loss, i get tc command not found. Will 1.4 version solve this issue as well?

no. if you use bare metal, you need install tc yum install iproute-tc

ntlzthm8 avatar Apr 28 '23 09:04 ntlzthm8