Skip to main content

Command Probe

The Command Probe allows developers to run Bash commands and match the resulting output as part of the entry/exit criteria. The intent behind this probe was to allow users to implement a non-standard & imperative way for expressing their hypothesis. For example, you can check for specific data within a database, parse the value out of a JSON blob being dumped into a certain path or check for the existence of a particular string in the service logs.

YAML Only Feature

By default, the probe can only be defined in inline mode from the UI where the command is run from within the experiment image. However, it can also be run in source mode where the command execution is carried out from within a new pod whose image can be specified. While inline is preferred for simple shell commands, source mode can be used when application-specific binaries are required. Refer to the probe schema here.

Where to define

The probes can be defined at .spec.experiments[].spec.probe path inside Chaos Engine.

kind: Workflow
apiVersion: argoproj.io/v1alpha1
spec:
templates:
- inputs:
artifacts:
- raw:
data: |
apiVersion: litmuschaos.io/v1alpha1
kind: ChaosEngine
spec:
experiments:
- spec:
probe:
####################################
Probes are defined here
####################################

Schema

Probe schema for CMD Probe with common properties shared across all probes and properties unique to CMD probe.

FieldDescriptionTypeRangeNotes
nameFlag to hold the name of the probeMandatoryN/A type: stringThe name holds the name of the probe. It can be set based on the usecase
typeFlag to hold the type of the probeMandatoryhttpProbe, k8sProbe, cmdProbe, promProbeThe type supports four types of probes. It can one of the httpProbe, k8sProbe, cmdProbe, promProbe
modeFlag to hold the mode of the probeMandatorySOT, EOT, Edge, Continuous, OnChaosThe mode supports five modes of probes. It can one of the SOT, EOT, Edge, Continuous, OnChaos
commandFlag to hold the command for the cmdProbeMandatoryN/A type: stringThe command contains the shell command, which should be run as part of cmdProbe
insecureSkipVerifyFlag to hold the flag to skip certificate checks for the httpProbeOptionaltrue, falseThe insecureSkipVerify contains flag to skip certificate checks.
responseTimeoutFlag to hold the flag to response timeout for the httpProbeOptionalN/A type: integerThe responseTimeout contains flag to provide the response timeout for the http Get/Post request.

Source

Source details for Command Probe.

FieldDescriptionTypeRangeNotes
imageFlag to hold the image for the cmdProbeOptionalany source docker imageThe image provides the source image which can be used to launch a external pod where the command execution is carried out.
hostNetworkDescription Flag to allow or deny the image access to the node network namespaceOptionaltrue, falseThe hostNetwork provides a possibility to allow the pod executing the cmdProbe access to the network of the node he is running on. For more details refer to the offical Kubernetes documentation.

Comparator

Comparator details for Command Probe.

FieldDescriptionTypeRangeNotes
typeFlag to hold type of the data used for comparisionMandatorystring, int, floatThe type contains type of data, which should be compare as part of comparision operation.
criteriaFlag to hold criteria for the comparisionMandatoryit supports >=, <=, ==, >, <, !=, oneOf, between for int & float type. And equal, notEqual, contains, matches, notMatches, oneOf for string type.The criteria contains criteria of the comparision, which should be fulfill as part of comparision operation.
valueFlag to hold value for the comparisionMandatoryN/A type: stringThe value contains value of the comparision, which should follow the given criteria as part of comparision operation.

Run Properties

Probe run properties for CMD Probe.

FieldDescriptionTypeRangeNotes
probeTimeoutFlag to hold the timeout of the probeMandatoryN/A type: integerThe probeTimeout represents the time limit for the probe to execute the specified check and return the expected data
retryFlag to hold the retry count of the probeMandatoryN/A type: integerThe retry contains the number of times a check is re-run upon failure in the first attempt before declaring the probe status as failed.
intervalFlag to hold the interval of the probeMandatoryN/A type: integerThe interval contains the interval for which probes waits between subsequent retries
probePollingIntervalFlag to hold the polling interval for the probes (applicable for all modes)OptionalN/A type: integerThe probePollingInterval contains the time interval for which continuous probe should be sleep after each iteration
initialDelaySecondsFlag to hold the initial delay interval for the probesOptionalN/A type: integerThe initialDelaySeconds represents the initial waiting time interval for the probes.
stopOnFailureFlags to hold the stop or continue the experiment on probe failureOptionalN/A type: booleanThe stopOnFailure can be set to true/false to stop or continue the experiment execution after probe fails

Definition

probe:
- name: "check-database-integrity"
type: "cmdProbe"
cmdProbe/inputs:
command: "<command>"
comparator:
type: "string" # supports: string, int, float
criteria: "contains" #supports >=,<=,>,<,==,!= for int and contains,equal,notEqual,matches,notMatches for string values
value: "<value-for-criteria-match>"
source: # omit this tag to "inline" the probe
image: "<repo>/<tag>"
hostNetwork: false
mode: "Edge"
runProperties:
probeTimeout: 5
interval: 5
retry: 1
initialDelaySeconds: 5