Prozessfehler simulieren
Diese Seite wurde von PageTurner AI übersetzt (Beta). Nicht offiziell vom Projekt unterstützt. Fehler gefunden? Problem melden →
Dieses Dokument beschreibt, wie Sie mit Chaosd Prozessfehler simulieren können. Die Prozessfehler nutzen die Golang-Schnittstelle des kill-Befehls, um Szenarien nachzubilden, bei denen ein Prozess abgebrochen oder gestoppt wird. Sie können Experimente sowohl im Kommandozeilenmodus als auch im Dienstmodus erstellen.
Experimente im Befehlszeilenmodus erstellen
Vor der Erstellung eines Experiments können Sie folgenden Befehl ausführen, um die von Chaosd unterstützten Prozessfehlertypen anzuzeigen:
chaosd attack process -h
Das Ergebnis sieht wie folgt aus:
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.
Aktuell unterstützt Chaosd die Simulation von Prozessabbrüchen oder Prozessstopps.
Prozessabbruch im Kommandozeilenmodus
Befehle für Prozessabbruch
chaosd attack process kill -h
Das Ergebnis sieht wie folgt aus:
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
Konfigurationsbeschreibung für Prozessabbruch
| Configuration item | Abbreviation | Description | Value |
|---|---|---|---|
process | p | The name or the identifier of the process to be injected faults | string; the default value is "". |
recover-cmd | r | The command to be run when recovering experiment | string; the default value is "". |
signal | s | The provided value of the process signal | int; the default value is 9. Currently, only SIGKILL, SIGTERM, and SIGSTOP are supported. |
Beispiel für Prozessabbruch
chaosd attack process kill -p python
Das Ergebnis sieht wie folgt aus:
Attack process python successfully, uid: 10e633ac-0a37-41ba-8b4a-cd5ab92099f9
Nur Experimente, deren signal auf SIGSTOP gesetzt ist, können wiederhergestellt werden.
Prozessstopp im Kommandozeilenmodus
Befehl für Prozessstopp
chaosd attack process stop -h
Das Ergebnis sieht wie folgt aus:
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'
Konfigurationsbeschreibung für Prozessstopp
| Configuration item | Abbreviation | Description | Value |
|---|---|---|---|
process | p | The name or the identifier of the process to be stopped | string; the default value is "". |
Beispiel für Prozessstopp
chaosd attack process stop -p python
Das Ergebnis sieht wie folgt aus:
Attack process python successfully, uid: 9cb6b3be-4f5b-4ecb-ae05-51050fcd0010
Experimente im Dienstmodus erstellen
Gehen Sie wie folgt vor, um Experimente im Dienstmodus zu erstellen:
-
Starten Sie Chaosd im Dienstmodus:
chaosd server --port 31767 -
Senden Sie eine
POST-HTTP-Anfrage an den Pfad/api/attack/processdes Chaosd-Dienstes:curl -X POST 172.16.112.130:31767/api/attack/process -H "Content-Type:application/json" -d '{fault-configuration}'Konfigurieren Sie
fault-configurationentsprechend den Fehlertypen. Die entsprechenden Parameter entnehmen Sie den Parametern und Beispielen der einzelnen Fehlertypen in den folgenden Abschnitten.
Notieren Sie sich beim Starten eines Experiments die UID des Experiments. Um das Experiment zu beenden, senden Sie eine DELETE-HTTP-Anfrage an den Pfad /api/attack/{uid} des Chaosd-Dienstes.
Prozessfehler im Dienstmodus simulieren
Parameter zur Simulation von Prozessfehlern
| Parameter | Description | Value |
|---|---|---|
process | The name or the identifier of the process to be injected faults | string; the default value is "". |
signal | The provided value of the process signal | int; the default value is 9 |
Beispiele zur Simulation von Prozessfehlern im Dienstmodus
Prozess beenden
curl -X POST 172.16.112.130:31767/api/attack/process -H "Content-Type:application/json" -d '{"process":"12345","signal":15}'
Das Ergebnis sieht wie folgt aus:
{"status":200,"message":"attack successfully","uid":"c3c519bf-819a-4a7b-97fb-e3d0814481fa"}
Prozess anhalten
curl -X POST 172.16.112.130:31767/api/attack/process -H "Content-Type:application/json" -d '{"process":"12345","signal":19}'
Das Ergebnis sieht wie folgt aus:
{"status":200,"message":"attack successfully","uid":"a00cca2b-eba7-4716-86b3-3e66f94880f7"}
Nur Experimente, deren signal auf SIGSTOP gesetzt ist, können wiederhergestellt werden.