ChaosBlade Documentation

repository·master·Indexed 27 days ago

https://github.com/chaosblade-io/chaosblade

An open-source chaos engineering toolkit for injecting faults into bare metal, containers, and Kubernetes clusters. It includes the ChaosBlade injection engine for resource, Java, C++, and cloud-native scenarios, and BLADE AI, an intelligent orchestration layer that provides natural-language fault injection, safety reviews, and automated recovery via a conversational TUI, structured CLI, or server mode.

Tokens
91.6K
Snippets
134
Records
453
Agent score
86%

What's inside ChaosBlade

  1. Overview of ChaosBlade

    master

    ChaosBlade is an open-source chaos engineering toolkit designed to improve the fault tolerance of distributed systems. It supports a wide range of experimental scenarios including:

    • Basic Resources: CPU, memory, network, disk, and processes.
    • Java Applications: Databases, caches, messages, JVM, and microservices (via Java Agent).
    • C++ Applications: Method and code line level injection (via GDB).
    • Containers: Docker container resource and process scenarios.
    • Cloud-Native (Kubernetes): Node, Pod, and Container level scenarios via the chaosblade-operator.
  2. Overview of BLADE AI

    master

    BLADE AI is the intelligent agent layer for the ChaosBlade ecosystem. It acts as an intelligent assistant that orchestrates ChaosBlade to perform fault injection through natural language rather than manual commands.

    Key distinctions:

    • ChaosBlade is the injection engine (handles how to inject, e.g., K8s Pod CPU stress or network packet loss).
    • BLADE AI is the orchestration layer (handles how to safely and completely complete an experiment). It manages intent understanding, safety reviews, effect verification, safe recovery, and structured reporting.

    The BLADE AI workflow follows a closed loop: IntentSafetyInjectionVerificationRecovery.

  3. Understand the Chaosblade command hierarchy

    master

    Chaosblade commands follow a specific logical flow: blade <command> <model> <action>.

    1. Primary Commands: Basic operations like version, prepare, revoke, and create.
    2. Model Objects (Nouns): These represent the target of the fault injection (e.g., cpu, disk, network, mem, jvm, k8s, or docker). These are implemented via the ExpModelCommandSpec interface.
    3. Actions (Verbs): These are the specific operations performed on a model (e.g., fullload for cpu, or delay/drop for network). These are implemented via the ExpActionCommandSpec interface.

    Example: blade create cpu fullload targets the cpu model to perform a fullload action.

  4. Understand the role of BLADE AI in Chaos Engineering

    master

    BLADE AI is an orchestration layer that sits on top of the ChaosBlade ecosystem. It does not replace ChaosBlade; instead, it acts as an intelligent assistant to make fault injection safer and more automated.

    Key distinctions:

    • ChaosBlade: The injection engine. It handles the technical implementation of how to inject faults (e.g., applying CPU pressure to a K8s Pod or dropping network packets).
    • BLADE AI: The orchestration layer. It handles the lifecycle of a fault drill, including intent understanding, safety reviews, effect verification, and reliable recovery.

    Use BLADE AI when you want to describe a fault in plain English rather than memorizing specific CLI flags and manual verification steps.

  5. Understand the relationship between ChaosBlade and BLADE AI

    master

    BLADE AI acts as an intelligent orchestration layer on top of the ChaosBlade injection engine. While ChaosBlade focuses on the mechanics of how to inject faults using structured commands, BLADE AI focuses on how to safely and completely run a chaos drill using natural language or structured parameters.

    Key differences include:

    • Input: ChaosBlade uses structured commands; BLADE AI uses natural language.
    • Safety: ChaosBlade leaves safety to the caller; BLADE AI includes a built-in 4-layer review (command → semantic → human → system).
    • Verification: ChaosBlade returns exit codes; BLADE AI performs two-layer verification (operational correctness + effect reality).
    • Recovery: ChaosBlade provides blade destroy; BLADE AI manages an independent recovery flow with two-layer verification and force-cleanup fallbacks.
    • Auditability: BLADE AI provides 3-layer memory, checkpointer persistence, and TaskTrace execution traces.
  6. Blade AI Agent: Capabilities and Limitations

    master

    The Blade AI Agent provides an intelligent layer over traditional ChaosBlade CLI commands.

    Advantages

    • Intelligent Design: Translates natural language (e.g., "make this pod's network slow") into specific fault types like pod-network-delay.
    • Automated Verification: Automatically executes validation steps (Layer 1/Layer 2) defined in Skills.
    • Built-in Safety: Automatically intercepts dangerous operations (e.g., blacklisted namespaces or conflicting faults).
    • Natural Language Interface: Supports the --nl parameter for easier interaction.

    Limitations & When NOT to use

    • Do NOT use for Emergency Recovery: If a production outage is occurring, use blade destroy directly. The Agent's reasoning loop adds unnecessary latency.
    • Do NOT use for Highly Customized Faults: If you need to inject specific HTTP error codes or modify application code, use specialized frameworks like Chaos Mesh or LitmusChaos.
    • Do NOT use for Massively Parallel Experiments: The Agent's serial execution mode is inefficient for hundreds of simultaneous Pod faults; use batch scripts instead.
    • LLM Dependency: The Agent relies on LLM reasoning. For high-precision tasks, bypass the LLM by providing structured parameters like --fault-type.
  7. Understand the Chaosblade Experiment Model

    master

    Chaosblade experiments are structured around a four-part model to ensure precision and control the 'explosion radius' of a fault. When designing or using an experiment, identify these four components:

    1. Target: The component being experimented on (e.g., container, dubbo, redis, network).
    2. Scope: The specific machine or cluster where the experiment is triggered. Note that for the blade CLI, the scope defaults to the local machine.
    3. Matcher: Rules used to identify the specific instance to affect (e.g., matching a specific Dubbo service name, a specific IP, or a specific port).
    4. Action: The specific fault scenario to simulate (e.g., delay, exception, disk full, packet loss).
  8. ChaosBlade Agent: Blade AI

    master
    Blade AI is an intelligent agent layer for the ChaosBlade ecosystem. It sits above the core ChaosBlade execution engine to provide orchestration capabilities such as intent understanding, security review, effect verification, safe recovery, and structured reporting. It transforms manual command-line fault injection into a natural language dialogue interface.
  9. BLADE AI Architecture Overview

    master

    BLADE AI is organized into four distinct layers:

    1. Access Layer: Provides interfaces via a CLI (built with Typer) and a Server (built with FastAPI + SSE) offering REST and Stream routes.
    2. Orchestration Layer: Uses a LangGraph StateGraph to manage the experiment lifecycle through three phases:
      • Phase 1: Planning
      • Safety Check
      • Phase 2: Execution
      • Phase 3: Verification It utilizes an AgentState (unified state model) and a Router (conditional routing).
    3. Capability Layer: Contains the core logic, including:
      • Tool System: Blade, Kubectl, and Guard.
      • Skill System: Tier 1-3 skills with progressive loading via a Registry.
      • Memory System: Working, Session, and Operational Memory.
    4. Infrastructure Layer: Handles persistence (SQLite or optional PG), observability (Tracer, Tracker, Stream), and configuration management (pydantic-settings).
  10. Understand the Chaosblade Fault Injection Model

    master

    Chaosblade uses a structured model to define chaos experiments, ensuring precise control over the blast radius. An experiment is composed of four key elements:

    • Target: The component being experimented on (e.g., dubbo, network, cpu, disk, redis).
    • Scope: The execution range, such as a specific host or cluster. Note that for the blade CLI, the scope defaults to the local machine.
    • Matcher: Rules used to match specific traffic or components (e.g., matching a specific Dubbo service name or a specific network port).
    • Action: The specific fault scenario to simulate (e.g., delay, loss, fullload).

    Example logic flow: Target (dubbo) -> Scope (local host) -> Matcher (service com.example.HelloService) -> Action (delay 3000ms).

  11. Understand the difference between Chaos Engineering and Traditional Testing

    master

    Chaos Engineering is the discipline of performing experiments on distributed systems to build confidence in the system's ability to withstand turbulent conditions. It differs from traditional testing in several key dimensions:

    DimensionTraditional TestingChaos Engineering
    GoalVerify the system works as expectedDiscover unknown weaknesses under abnormal conditions
    MethodDeterministic input $\rightarrow$ Deterministic outputRandom/controlled perturbations $\rightarrow$ Observe system behavior
    ScopeUnit, integration, and end-to-end testsReal traffic in production or staging environments
    Assumption"We know all possible failure modes""We don't know how the system will fail"
    MindsetProve the system is correctFalsify the system's resilience hypotheses

    Key Concept: Chaos Engineering is not about "breaking the system," but about "improving system resilience through controlled experiments."

  12. Understand the BLADE AI Three-Phase ReAct State Machine

    master

    BLADE AI uses a LangGraph-based three-phase ReAct state machine to manage fault injection workflows. This separation ensures stability and prevents prompt bloat by giving each phase a specific focus, toolset, and loop limit:

    1. Phase 1: Planning — Translates natural language intent into an execution plan. It matches skills, queries target states, and requires rich context (skill directories, K8s resource info).
    2. Phase 2: Execution — Calls ChaosBlade to create experiments and verifies the immediate return. Focuses on precise tool calls and error handling.
    3. Phase 3: Verification — Confirms the fault is actually active and can be recovered. Uses time-based strategies like delayed waiting and polling.

    If Phase 2 fails due to recoverable errors (e.g., missing resources), the system can trigger a Replan (up to 3 attempts) to return to Phase 1.