模拟进程故障
在创建进程故障实验前,可运行以下命令行查看 Chaosd 支持的进程故障类型:
输出结果如下所示:
Process attack related commands
Usage:
chaosd attack process [command]
Available Commands:
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.
目前 Chaosd 支持模拟进程被终止或暂停的故障。
模拟进程被终止命令
chaosd attack process kill -h
输出结果如下所示:
kill process, default signal 9
Usage:
chaosd attack process kill [flags]
Flags:
-h, --help help for kill
-r, --recover-cmd string The command to be run when recovering experiment
-s, --signal int The signal number to send (default 9)
--log-level string the log level of chaosd. The value can be 'debug', 'info', 'warn' and 'error'
--uid string the experiment ID
模拟进程被终止相关配置说明
模拟进程被终止示例
chaosd attack process kill -p python
输出结果如下所示:
只有 signal
为 SIGSTOP
的实验支持被恢复。
模拟进程被暂停命令
chaosd attack process stop -h
输出结果如下所示:
stop process, this action will stop the process with SIGSTOP
Usage:
chaosd attack process stop [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'
模拟进程被暂停相关配置说明
模拟进程被暂停示例
chaosd attack process stop -p python
输出结果如下所示:
Attack process python successfully, uid: 9cb6b3be-4f5b-4ecb-ae05-51050fcd0010
使用服务模式创建实验
要使用服务模式创建实验,请进行以下操作:
以服务模式运行 Chaosd。
-
curl -X POST 172.16.112.130:31767/api/attack/process -H "Content-Type:application/json" -d '{fault-configuration}'
在上述命令中,你需要按照故障类型在 fault-configuration
中进行配置。有关对应的配置参数,请参考下文中各个类型故障的相关参数说明和命令示例。
注意
在运行实验时,请注意保存实验的 UID 信息。当要结束 UID 对应的实验时,需要向 Chaosd 服务的路径 /api/attack/{uid}
发送 DELETE
HTTP 请求。
进程故障相关参数说明
使用服务模式模拟进程故障示例
进程被终止
curl -X POST 172.16.112.130:31767/api/attack/process -H "Content-Type:application/json" -d '{"process":"12345","signal":15}'
输出如下所示:
进程被暂停
curl -X POST 172.16.112.130:31767/api/attack/process -H "Content-Type:application/json" -d '{"process":"12345","signal":19}'
输出如下所示:
只有 signal
为 SIGSTOP
的实验支持被恢复。