-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
There is a problem with the data type of Attributes and pods in class Selector. It should be a dictionary instead of a list.
Reproduction steps
I follow the official documentation to inject faults into the service. The script is as follows:
import uuid
from chaosmesh.client import Client, Experiment
from chaosmesh.k8s.selector import Selector
# creating the ChaosMesh client
client = Client(version="v1alpha1")
# target pods selector; by labelSector or by pods in specified namespaces
selector = Selector(labelSelectors=None, pods=["my-cnosdb-meta-0"], namespaces=["cnosdb-community-latest-3meta-2querytskv"])
print(selector);
exp_name = str(uuid.uuid4())
# starting up the pod kill experiment
client.start_experiment(Experiment.POD_KILL, namespace="cnosdb-community-latest-3meta-2querytskv", name=exp_name, selector=selector)
but the result as follow:
admission webhook "mpodchaos.kb.io" denied the request: json: cannot unmarshal array into Go struct field PodSelectorSpec.spec.selector.pods of type map[string][]string",
Later, I changed the type of pods and wrote it as a dictionary. I found that the injection failure was normal as follows:
import uuid
from chaosmesh.client import Client, Experiment
from chaosmesh.k8s.selector import Selector
# creating the ChaosMesh client
client = Client(version="v1alpha1")
# target pods selector; by labelSector or by pods in specified namespaces
selector = Selector(labelSelectors=None, pods={"cnosdb-community-latest-3meta-2querytskv": ["my-cnosdb-meta-0"]}, namespaces=["cnosdb-community-latest-3meta-2querytskv"])
print(selector);
exp_name = str(uuid.uuid4())
# starting up the pod kill experiment
client.start_experiment(Experiment.POD_KILL, namespace="cnosdb-community-latest-3meta-2querytskv", name=exp_name, selector=selector)
the result:
root@ubuntu:/home/bca/code/python3# python3 test_chaos_mesh.py
Selector(namespaces=['cnosdb-community-latest-3meta-2querytskv'], labelSelectors=None, pods={'cnosdb-community-latest-3meta-2querytskv': ['my-cnosdb-meta-0']})
INFO:chaosmesh:starting POD_KILL experiment bbe09fd5-cd7d-4db6-8d0a-53ab85c57f0c in cnosdb-community-latest-3meta-2querytskv namespace
INFO:chaosmesh:chaosmesh experiment bbe09fd5-cd7d-4db6-8d0a-53ab85c57f0c got applied
root@ubuntu:/home/bca/code/python3# python3 test_chaos_mesh.py
...
Expected behavior
1
Additional context
1
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working