litmuschaos / litmus

Litmus helps SREs and developers practice chaos engineering in a Cloud-native way. Chaos experiments are published at the ChaosHub (https://hub.litmuschaos.io). Community notes is at https://hackmd.io/a4Zu_sH4TZGeih-xCimi3Q
https://litmuschaos.io
Apache License 2.0
4.45k stars 698 forks source link

When using Litmus 2.1.0, the cmdProbe 'source' value is always invalid #3349

Open aasserzo opened 3 years ago

aasserzo commented 3 years ago

What happened: Assuming the 2.1.0 operator is installed, and the appropriate RBAC yaml is applied, When the chaosengine yaml is applied with the following probe:

    - name: "node not in Ready state"
      type: "cmdProbe"
      cmdProbe/inputs:
        command: "kubectl get node/worker-0-1 -o jsonpath='{.status.conditions[?(@.status==\"True\")].type}'"
        comparator:
          type: "string"
          criteria: "equal"
          value: ""
        source: "inline"
      mode: "Continuous"
      runProperties:
        probeTimeout: 20
        interval: 1
        retry: 1
        initialDelaySeconds: 60

Then the following error is thrown:

The ChaosEngine "node-poweroff" is invalid: spec.experiments.spec.probe.cmdProbe/inputs.source: Invalid value: "string": spec.experiments.spec.probe.cmdProbe/inputs.source in body must be of type object: "string"

What you expected to happen: I expect this probe to pass validation, as it does in Litmus 2.0.0

How to reproduce it (as minimally and precisely as possible): Install Litmus operator 2.1.0 Apply a chaosengine yaml with the aforementioned probe in the experiment spec

Anything else we need to know?: This works as-is in Litmus 2.0.0

aleksei-budiak commented 2 years ago

Hi @aasserzo, I've faced this bug too. I've found that it's caused by recent change to the cmdProbe structure, you can see the source here: https://github.com/litmuschaos/chaos-operator/blob/7e75803234f80c608c22306f844577a4f69431f5/pkg/apis/litmuschaos/v1alpha1/chaosengine_types.go#L230

Apparently, the docs weren't updated after the change.

Now the source is indeed an object, but not a string. To replicate the inline behaviour on newer versions, just omit the source field.

aasserzo commented 2 years ago

Hi @aasserzo, I've faced this bug too. I've found that it's caused by recent change to the cmdProbe structure, you can see the source here: https://github.com/litmuschaos/chaos-operator/blob/7e75803234f80c608c22306f844577a4f69431f5/pkg/apis/litmuschaos/v1alpha1/chaosengine_types.go#L230

Apparently, the docs weren't updated after the change.

Now the source is indeed an object, but not a string. To replicate the inline behaviour on newer versions, just omit the source field.

Thanks for your comment! I will omit the source field and start using a later release. I do think, however, this should be addressed in documentation, and a more informative error should be worded.

christopherfriedrich commented 2 years ago

How can this work in Litmus v2.0.x, when the change in the mentioned CRD was introduced with that version?