chaosblade-io / chaosblade

An easy to use and powerful chaos engineering experiment toolkit.(阿里巴巴开源的一款简单易用、功能强大的混沌实验注入工具)
https://chaosblade.io
Apache License 2.0
5.86k stars 934 forks source link

illegal `path` parameter value: `/path-not-on-host`. it must be a directory #1015

Open 89yanyu opened 3 months ago

89yanyu commented 3 months ago

Issue Description

Type: bug report

Describe what happened (or what feature you want)

I try to create the pod-disk fill injection using url and it is created failed.

curl -v http://11.140.167.216:9526/chaosblade?cmd=create%20k8s%20pod-disk%20fill%20--path%20/path-not-on-host%20--names%20chaos-test%20--namespace%20default%20--kubeconfig%20/root/.kube/config%20--percent%2020
{
    "code": 54000,
    "success": false,
    "error": "illegal `path` parameter value: `/path-not-on-host`. it must be a directory",
    "result": {
        "error": "illegal `path` parameter value: `/path-not-on-host`. it must be a directory",
        "statuses": [
            {
                "error": "illegal `path` parameter value: `/path-not-on-host`. it must be a directory",
                "identifier": "default/11.140.167.216/chaos-test/chaos-test/180df34b3c94/docker",
                "kind": "pod",
                "state": "Error",
                "success": false
            }
        ],
        "success": false,
        "uid": "56f1e63091f5ac86"
    }
}

and I checked path which I injected:

# kubectl exec -it chaos-test -- ls /
bin               lib64             path-not-on-host  sys
dev               linuxrc           proc              tmp
etc               media             root              usr
home              mnt               run               var
lib               opt               sbin

Describe what you expected to happen

Inject succeefully and disk will be filled to 20%

How to reproduce it (as minimally and precisely as possible)

  1. prepare kubernetes enviroment
  2. install chaosblade-operator
  3. create a pod with volume and the mount path have to be not same as host path
    apiVersion: v1
    kind: Pod
    metadata:
    name: chaos-test
    namespace: default
    spec:
    restartPolicy: Never
    volumes:
    - name: vol
    hostPath:
      path: /data
    containers:
    - name: chaos-test
    image: "registry.k8s.io/busybox"
    command: ["/bin/sh", "-c", "while true; do sleep 1000; done"]
    volumeMounts:
    - name: vol
      mountPath: /path-not-on-host
  4. use the url above to inject and error will be got

Tell us your environment

CentOS8 chaosblade-operator 1.7.2

Anything else we need to know?

I checked source code with 1.7.2. I found that pod-disk fill will check whether the path is a directory out of namespace. source code