Skip to main content
Version: Next

Simulate Disk Faults

This document describes how to use Chaosd to simulate disk faults. This feature helps you simulate disk read/write load (via dd) or disk fill (via dd or fallocate).

info

Chaosd v1.5.0 and later

Disk read and write workloads stop when the requested data size is reached or duration expires, whichever happens first. Use a duration such as 30s or 1m; an empty value sets no workload deadline. This deadline behavior was fixed in v1.5.0 and applies to both CLI and service mode. It does not apply to disk fill.

Before creating an experiment, you can run the following command to check the types of disk faults that are supported by Chaosd:

chaosd attack disk -h

Currently, Chaosd supports creating disk read load experiments, disk write load experiments, and disk fill experiments.

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/disk path of the Chaosd service:

chaosd server --port 31767
curl -X POST 172.16.112.130:31767/api/attack/disk -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.

info

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.

Simulate disk read load​

Parameters for simulating disk read load​

Configuration itemAbbreviationService mode fieldDescriptionTypeValue
action—actionActions of the experimentstringSet to "read-payload".
pathppathSpecifies the file path to read the data. If this parameter is not specified, or the parameter value is set to an empty string, Chaosd reads from the virtual disk files mounted in the "/" directory. Depending on the permissions to read the files, you might be required to run this program using certain permissions.stringdefault: ""
process-numnpayload-process-numSpecifies the number of concurrently running dd programs to be used.uint8default: 1; range: 1 to 255
sizessizeSpecifies the volume of data to be read. It is the total size of data that dd reads.stringdefault: ""; required; legal form: the combination of an integer and a unit. For example, 1M, 512kB. Supported units are c=1, w=2, b=512, kB=1000, K=1024, MB=1000*1000, M=1024*1024, GB=1000*1000*1000, G=1024*1024*1024*1024 BYTE and so on.
durationNonedurationMaximum read/write workload duration, such as 30s. The workload can finish earlier after processing the requested data size.stringDefault: "", no workload deadline.

Simulate disk read load using the command-line mode​

Simulating disk read load is a one-time operation, so the experiment does not need to be recovered.

chaosd attack disk add-payload read -h
chaosd attack disk add-payload read -s 1000G -n 7 -p /dev/zero

Simulate disk read load using the service mode​

curl -X POST 172.16.112.130:31767/api/attack/disk -H "Content-Type:application/json" -d '{"action":"read-payload","path":"/dev/zero", "payload-process-num":7,"size":"1000G"}'

Simulate disk write load​

Parameters for simulating disk write load​

Configuration itemAbbreviationService mode fieldDescriptionTypeValue
action—actionActions of the experimentstringSet to "write-payload".
pathppathSpecifies the file path to write the data. If this parameter is not specified, or the parameter value is set to an empty string, a temporary file will be created in the program execution directory. Depending on the permissions to write the files, you might be required to run this program using certain permissions.stringdefault: ""
process-numnpayload-process-numSpecifies the number of concurrently running dd programs to be used.uint8default: 1; range: 1 to 255
sizessizeSpecifies the volume of data to be written. It is the total size of data that dd writes.stringdefault: ""; required; legal form: the combination of an integer and a unit. For example, 1M, 512kB. Supported units are c=1, w=2, b=512, kB=1000, K=1024, MB=1000*1000, M=1024*1024, GB=1000*1000*1000, G=1024*1024*1024*1024 BYTE and so on.
durationNonedurationMaximum read/write workload duration, such as 30s. The workload can finish earlier after processing the requested data size.stringDefault: "", no workload deadline.

Simulate disk write load using the command-line mode​

chaosd attack disk add-payload write -h
chaosd attack disk add-payload write -s 2G -n 8

Simulate disk write load using the service mode​

curl -X POST 172.16.112.130:31767/api/attack/disk -H "Content-Type:application/json" -d '{"action":"write-payload","path":"/tmp/test", "payload-process-num":7,"size":"1000G"}'

Simulate disk fill​

Parameters for simulating disk fill​

Configuration itemAbbreviationService mode fieldDescriptionTypeValue
action—actionActions of the experimentstringSet to "fill".
fallocateffallocateIf this parameter is set to true, Linux is used to call fallocate to quickly apply for disk space and size must be greater than 0. If this parameter is set to false, Linux is used to call dd to fill disks at a relatively slow pace.booldefault: true
pathppathSpecifies the file path to write the data. If this parameter is not specified, or the parameter value is set to an empty string, a temporary file will be created in the program execution directory. Depending on the permissions to write the files, you might be required to run this program using certain permissions.stringdefault: ""
percentcpercentSpecifies the percentage of disk size to be filled.stringdefault: ""; positive integer of the uint type is acceptable; you must set one of size or percent (both items cannot be "" at the same time).
sizessizeSpecifies the volume of data to be written.stringdefault: ""; legal form: the combination of an integer and a unit. For example, 1M, 512kB. Supported units are c=1, w=2, b=512, kB=1000, K=1024, MB=1000*1000, M=1024*1024, GB=1000*1000*1000, G=1024*1024*1024*1024 BYTE and so on. You must set one of size or percent (both items cannot be "" at the same time).

Simulate disk fill using the command-line mode​

chaosd attack disk fill -h
chaosd attack disk fill -c 50

Simulate disk fill using the service mode​

curl -X POST 172.16.112.130:31767/api/attack/disk -H "Content-Type:application/json" -d '{"action":"fill","path":"/tmp/test", "fallocate":true,"percent":"50"}'