Skip to main content
Version: 2.6.7

Simulate Process Faults

This document describes how to use Chaosd to simulate process faults. The process faults use the Golang interface of the kill command to simulate the scenarios that the process is killed or stopped. You can create experiments either in the command-line mode or service mode.

Before creating an experiment, you can run the following command to see the process fault types that are supported by Chaosd:

chaosd attack process -h

The result is as follows:

Process attack related commands

Usage:
chaosd attack process [command]

Available Commands:
kill kill process, default signal 9
stop stop process, this action will stop the process with SIGSTOP

Flags:
-h, --help help for process

Global Flags:
--log-level string the log level of chaosd, the value can be 'debug', 'info', 'warn' and 'error'

Use "chaosd attack process [command] --help" for more information about a command.

Currently, Chaosd supports simulating that a process is killed or stopped.

To create experiments using the service mode, you need to run Chaosd in the service mode and then send a POST HTTP request to the /api/attack/process path of the Chaosd service:

chaosd server --port 31767
curl -X POST 172.16.112.130:31767/api/attack/process -H "Content-Type:application/json" -d '{fault-configuration}'

For the fault-configuration part in the above command, you need to configure it according to the fault types. For the corresponding parameters and examples, refer to the parameters of each fault type in the following sections.

note

When running an experiment, remember to record the UID of the experiment. When you want to end the experiment corresponding to the UID, you need to send a DELETE HTTP request to the /api/attack/{uid} path of the Chaosd service.

Kill a process

Parameters for killing a process

Configuration itemAbbreviationService mode fieldDescriptionTypeValue
processpprocessThe name or the identifier of the process into which faults are injectedstringThe default value is "".
recover-cmdrrecover-cmdThe command to be run when recovering experimentstringThe default value is "".
signalssignalThe provided value of the process signalintThe default value is 9. Currently, only SIGKILL, SIGTERM, and SIGSTOP are supported.

Kill a process using the command-line mode

Run the following command to see the commands for killing a process:

chaosd attack process kill -h

The result is as follows:

kill process, default signal 9

Usage:
chaosd attack process kill [flags]

Flags:
-h, --help help for kill
-p, --process string The process name or the process ID
-r, --recover-cmd string The command to be run when recovering experiment
-s, --signal int The signal number to send (default 9)

Global Flags:
--log-level string the log level of chaosd. The value can be 'debug', 'info', 'warn' and 'error'
--uid string the experiment ID

The example for killing a process is as follows:

chaosd attack process kill -p python

The result is as follows:

Attack process python successfully, uid: 10e633ac-0a37-41ba-8b4a-cd5ab92099f9
note

Only the experiments whose signal is SIGSTOP or that configure recover-cmd can be recovered.

Kill a process using the service mode

Terminate a process:

curl -X POST 172.16.112.130:31767/api/attack/process -H "Content-Type:application/json" -d '{"process":"12345","signal":15}'

The result is as follows:

{"status":200,"message":"attack successfully","uid":"c3c519bf-819a-4a7b-97fb-e3d0814481fa"}

Stop a process

Parameters for stopping a process

Configuration itemAbbreviationService mode fieldDescriptionTypeValue
processpprocessThe name or the identifier of the process to be stoppedstringThe default value is "".
signalsignalThe provided value of the process signalintThe default value is 9.

Stop a process using the command-line mode

Run the following command to see the command for stopping a process:

chaosd attack process stop -h

The result is as follows:

stop process, this action will stop the process with SIGSTOP

Usage:
chaosd attack process stop [flags]

Flags:
-h, --help help for stop
-p, --process string The process name or the process ID

Global Flags:
--log-level string the log level of chaosd, the value can be 'debug', 'info', 'warn' and 'error'

The example for stopping a process is as follows:

chaosd attack process stop -p python

The result is as follows:

Attack process python successfully, uid: 9cb6b3be-4f5b-4ecb-ae05-51050fcd0010

Stop a process using the service mode

Stop a process:

curl -X POST 172.16.112.130:31767/api/attack/process -H "Content-Type:application/json" -d '{"process":"12345","signal":19}'

The result is as follows:

{"status":200,"message":"attack successfully","uid":"a00cca2b-eba7-4716-86b3-3e66f94880f7"}