chaos-mesh icon indicating copy to clipboard operation
chaos-mesh copied to clipboard

failed to create an experiment by loading an existing experiment

Open lhh-yeah opened this issue 2 years ago • 2 comments

Bug Report

What version of Kubernetes are you using?

1.24.4 What version of Chaos Mesh are you using?

2.6.0 What did you do? / Minimal Reproducible Example

Failed to create an experiment by loading an existing experiment.

schedules and workflows have the same problem

image

image

What did you expect to see?

What did you see instead?

Output of chaosctl

lhh-yeah avatar Jun 27 '23 04:06 lhh-yeah

This is a difficult problem to troubleshoot, and I can start by trying to explain to you why there is often an error when loading a resource that has already been created.

Chaos Mesh has different types of chaos, and each chaos can be used in a schedule. The fields of each chaos are not the same. For example, if a chaos has an action field to specify its behavior, then it will not have the same structure as a StressChaos, such as a NetworkChaos.

Then the problem turns to how to validate different chaos and place its fields in the correct positions to generate a yaml in the frontend? Now it is implemented in a rather "ugly" way, i.e. the front end manually writes a structure corresponding to all CRDs, in https://github.com/chaos-mesh/chaos-mesh/blob/master/ui/app/src/components/NewExperimentNext/data/types.ts.

Normally, the front end should rely on the API server to get the spec of chaos. This will completely avoid the synchronization problems caused by updating the CRD.

We've already planned to ~~get the specs by API and~~ write a common package to validate different specs that can be used both in Kubernetes and API server. I will create an issue to track.

Back to your question, would you mind providing the schedule that is causing the error? I will troubleshoot why.

Updated (2023-07-02):

I forgot we already have a method to generate the spec of chaos. The method can be found at https://github.com/chaos-mesh/chaos-mesh/blob/master/ui/packages/openapi/README.md. The only difference of this method is it is static, which means it must be used after being generated manually.

g1eny0ung avatar Jun 28 '23 09:06 g1eny0ung

After the discussion with @g1eny0ung, we find that the validation feature is required to give a better experience to user, for indicating which exact fields are invalid.

https://github.com/chaos-mesh/chaos-mesh/issues/2559

STRRL avatar Jul 02 '23 01:07 STRRL