agentleFS
dungnotnulldungnotnull/hybrid-harness-chaos-process-prm/skills/s18-infrastructure-faults/SKILL.md

chaos-infrastructure-faults

Skill19 starsChanged 6 months agoMITView on GitHub

Design and execute infrastructure-level chaos experiments targeting nodes, disks, CPU, memory, network, and cloud resources. Use this skill whenever the user says "test node failure", "drain a node", "fill disk", "test CPU exhaustion", "simulate AZ failure", "stop EC2 instances", or needs infrastructure-level fault injection manifests for LitmusChaos or Harness Chaos Engineering. Also trigger as part of the chaos experiment design phase (s16 follows s12).

  • Deletes or force-pushes

The file

Files
SKILL.md

Chaos Infrastructure Faults (s16)

Purpose

Produce complete, safe, runnable infrastructure-level chaos experiments that test system resilience against node failures, resource exhaustion, disk pressure, and cloud provider outages.


Prerequisites

  • Chaos experiment designs from s14 (Experiment Design)
  • Delegate configured from s06 (Delegate Management)
  • Kubernetes cluster access for infrastructure operations
  • Steady state defined from s17 (Steady State)
  • Blast radius approved from s16 (Blast Radius Control)
  • Observability active and monitoring targets

Input Contract

InputSourceRequired
Experiment design frameworks12 (workflow_context.artifacts)Yes
Blast radius constraintss14 outputYes
Infrastructure topology (nodes, AZs, regions)s01 or s05 contextYes
Cloud provider (AWS/GCP/Azure)s01 contextYes
Risk tolerance (prod limits)s02 taste (risk_tolerance)Yes
Delegate/cluster access infos06 outputYes

Output Contract

OutputDestinationFormat
Infra fault ChaosExperiments.commandcode/artifacts/experiment-infra-<fault>.yamlLitmus YAML
Infra fault ChaosEngines.commandcode/artifacts/engine-infra-<fault>.yamlLitmus YAML
Cloud-specific fault configs.commandcode/artifacts/experiment-<cloud>-<fault>.yamlYAML
Recovery runbooks18 (game day), s25 (postmortem)Markdown
Infra fault risk assessments21 (alerting context)YAML

Infrastructure Fault Catalog

FaultLitmusChaos NameRisk LevelMin ReplicasProd Safe?
Node CPU Hognode-cpu-hogMedium3+ nodesWith 30% max
Node Memory Hognode-memory-hogMedium3+ nodesWith 30% max
Node Drainnode-drainHigh3+ nodesWith PDB + approval
Node Restartnode-restartCritical3+ nodesNo (staging only)
Disk Filldisk-fillHighN/AWith ephemeral only
Disk Loss (EBS)ebs-lossCriticalN/ANo (staging only)
EC2 Stop (AWS)ec2-stopCriticalN/ANo (staging only)
AZ Failure (AWS)— (composite)ExtremeMulti-AZGame day only
GCP VM Stopgcp-vm-stopCriticalN/ANo (staging only)
Azure VM Stopazure-vm-stopCriticalN/ANo (staging only)

Fault 1: Node CPU Hog

# Generated by: hybrid-harness-chaos-process-prm
apiVersion: litmuschaos.io/v1alpha1
kind: ChaosExperiment
metadata:
  name: node-cpu-hog
  namespace: litmus
  labels:
    managed-by: hcprm
    fault-category: infrastructure
    fault-type: resource-exhaustion
spec:
  definition:
    scope: Cluster
    permissions:
      - apiGroups: [""]
        resources: ["nodes"]
        verbs: ["get", "list", "patch"]
      - apiGroups: ["litmuschaos.io"]
        resources: ["chaosengines", "chaosexperiments", "chaosresults"]
        verbs: ["create", "get", "list", "patch", "update", "watch"]
    image: litmuschaos/go-runner:latest
    args: ["-c", "./experiments/node-cpu-hog"]
    command: ["/bin/bash"]
    env:
      - name: TOTAL_CHAOS_DURATION
        value: "120"
      - name: CPU_CORES
        value: "2"             # Number of cores to consume
      - name: CPU_LOAD
        value: "80"            # Percentage load on those cores
      - name: TARGET_NODES
        value: ""              # Empty = random selection
      - name: NODE_AFFECTED_PERC
        value: "33"            # % of nodes to target
      - name: NODE_LABEL
        value: ""              # Optional: target specific nodes
      - name: RAMP_TIME
        value: "30"
apiVersion: litmuschaos.io/v1alpha1
kind: ChaosEngine
metadata:
  name: node-cpu-hog-engine
  namespace: litmus
  labels:
    managed-by: hcprm
spec:
  appinfo:
    appns: litmus
    applabel: "app=chaos-runner"
    appkind: deployment
  chaosServiceAccount: litmus-cluster-scope   # Cluster-level SA required
  monitoring: true
  jobCleanUpPolicy: retain
  annotationCheck: "false"                     # Infrastructure — pods not required
  engineState: active
  experiments:
    - name: node-cpu-hog
      spec:
        probe:
          - name: node-health-check
            type: cmdProbe
            mode: Continuous
            cmdProbe/inputs:
              command: |
                kubectl get nodes --no-headers | awk '{print $2}' | grep -cv Ready
              comparator:
                type: int
                criteria: "<="
                value: "1"      # At most 1 node can be NotReady
            runProperties:
              probeTimeout: 10s
              interval: 15s
              retry: 2
              stopOnFailure: true
          - name: cluster-cpu-check
            type: promProbe
            mode: Continuous
            promProbe/inputs:
              endpoint: "http://prometheus.monitoring.svc.cluster.local:9090"
              query: |
                100 - avg(rate(node_cpu_seconds_total{mode="idle"}[2m])) * 100
              comparator:
                type: float
                criteria: "<="
                value: "90"
            runProperties:
              probeTimeout: 10s
              interval: 15s
              retry: 2
              stopOnFailure: true
        components:
          env:
            - name: TOTAL_CHAOS_DURATION
              value: "120"
            - name: CPU_CORES
              value: "2"
            - name: CPU_LOAD
              value: "80"
            - name: NODE_AFFECTED_PERC
              value: "33"

Fault 2: Node Drain

apiVersion: litmuschaos.io/v1alpha1
kind: ChaosExperiment
metadata:
  name: node-drain
  namespace: litmus
  labels:
    managed-by: hcprm
    fault-category: infrastructure
    fault-type: node-failure
spec:
  definition:
    scope: Cluster
    env:
      - name: TOTAL_CHAOS_DURATION
        value: "300"            # 5 minutes of drain
      - name: TARGET_NODE
        value: ""               # Target specific node or random
      - name: DRAIN_TIMEOUT
        value: "240"            # Max wait for pods to evict
      - name: NODE_LABEL
        value: ""               # Filter by label
      - name: FORCE
        value: "false"          # Force drain even with PDB violations

Pre-drain safety checks:

#!/bin/bash
# pre-drain-check.sh
TARGET_NODE="${1:?Usage: $0 <node-name>}"

echo "=== Pre-Drain Safety Check for $TARGET_NODE ==="

# 1. Verify cluster has >= 3 healthy nodes
HEALTHY_NODES=$(kubectl get nodes --no-headers | grep -c Ready)
if [ "$HEALTHY_NODES" -lt 3 ]; then
  echo "❌ ABORT: Only $HEALTHY_NODES healthy nodes (need ≥ 3)"
  exit 1
fi

# 2. Verify no single-replica stateful pods on target node
SINGLE_REPLICAS=$(kubectl get pods --all-namespaces --field-selector spec.nodeName=$TARGET_NODE \
  -o json | jq -r '.items[] | select(.metadata.ownerReferences[].kind=="StatefulSet") | "\(.metadata.namespace)/\(.metadata.name)"')

if [ -n "$SINGLE_REPLICAS" ]; then
  echo "⚠️  Stateful pods on target node:"
  echo "$SINGLE_REPLICAS"
  echo "Verify these have >1 replicas before draining."
fi

# 3. Verify PodDisruptionBudgets won't block drain
kubectl get pdb --all-namespaces | awk '$4 > 0 {print "⚠️  " $1 "/" $2 " allows " $4 " disruptions"}'

echo "✅ Pre-drain checks passed"

Fault 3: Disk Fill

apiVersion: litmuschaos.io/v1alpha1
kind: ChaosExperiment
metadata:
  name: disk-fill
  namespace: litmus
  labels:
    managed-by: hcprm
    fault-category: infrastructure
    fault-type: storage-exhaustion
spec:
  definition:
    scope: Namespaced
    env:
      - name: TOTAL_CHAOS_DURATION
        value: "180"
      - name: FILL_PERCENTAGE
        value: "80"             # Fill to 80% of available space
      - name: EPHEMERAL_STORAGE_MEBIBYTES
        value: "1024"           # Use 1GB ephemeral storage
      - name: TARGET_PODS
        value: ""
      - name: PODS_AFFECTED_PERC
        value: "100"
      - name: CONTAINER_PATH
        value: "/var/lib/data"  # Path inside container to fill
      - name: DATA_BLOCK_SIZE
        value: "256"            # Block size in KB

Fault 4: AWS EC2 Stop (Cloud-Level)

apiVersion: litmuschaos.io/v1alpha1
kind: ChaosExperiment
metadata:
  name: ec2-stop-by-tag
  namespace: litmus
  labels:
    managed-by: hcprm
    fault-category: cloud
    fault-type: instance-failure
spec:
  definition:
    scope: Cluster
    env:
      - name: TOTAL_CHAOS_DURATION
        value: "180"
      - name: EC2_INSTANCE_TAG
        value: "chaos-target:true"
      - name: INSTANCE_AFFECTED_PERC
        value: "25"
      - name: REGION
        value: "us-east-1"

Cloud Provider IAM Requirements

AWS

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": [
        "ec2:StopInstances",
        "ec2:StartInstances",
        "ec2:DescribeInstances",
        "ec2:DescribeInstanceStatus"
      ],
      "Resource": "*",
      "Condition": {
        "StringEquals": {
          "aws:RequestedRegion": "us-east-1"
        }
      }
    }
  ]
}

GCP

# Service account roles required:
# - Compute Instance Admin (v1) — for VM stop/start
# - Compute Viewer — for describe/list

Azure

{
  "role": "Virtual Machine Contributor",
  "scope": "/subscriptions/<SUB_ID>/resourceGroups/<RG>"
}

Recovery Procedures

Node CPU Hog Recovery

# CPU hog is self-recovering — process terminates at end of chaos duration
# Verify node CPU returns to baseline:
kubectl top nodes | grep <NODE_NAME>
# Expected: CPU% returns to pre-chaos levels within 60s

Node Drain Recovery

# Uncordon the node:
kubectl uncordon <NODE_NAME>

# Verify pods reschedule:
kubectl get pods --all-namespaces --field-selector spec.nodeName=<NODE_NAME> -w

# Verify node is Ready:
kubectl get node <NODE_NAME>

Disk Fill Recovery

# Chaos runner cleans up the filled data automatically
# Verify disk usage returns to normal:
kubectl exec -it <POD_NAME> -- df -h <CONTAINER_PATH>

# If manual cleanup needed:
kubectl exec -it <POD_NAME> -- rm -rf /var/lib/data/diskfill/*

Risk Matrix

FaultDev RiskStaging RiskProd RiskRecommended Gates
Node CPU Hog (30%)LowLowLowPDB + 3+ nodes
Node CPU Hog (80%)MediumMediumHighSRE approval + PDB
Node Memory HogMediumMediumHighSRE approval + PDB
Node DrainHighMediumCriticalSRE + CTO approval
Disk FillMediumMediumHighEphemeral only in prod
EC2/EBS StopCriticalHighExtremeGame day only, full backup

AI Agent Integration

Autonomy Level

AspectLevelDescription
CurrentL1AI generates infrastructure fault manifests
TargetL2AI targets infra components and generates fault YAML

Harness AI Agent

Agent: Harness AI Reliability Agent Capabilities:

  • Infrastructure fault manifest generation
  • Node/disk/CPU/cloud fault targeting
  • Fault parameter optimization

Human Gates

  • Production infrastructure fault approval
  • Cloud provider fault approval (EC2 stop, etc.)

MCP

  • LitmusChaos MCP
  • AWS FIS + Amazon Bedrock (natural language experiment generation)

Success Criteria

  • All fault manifests validate with kubectl apply --dry-run=client
  • Pre-flight safety checks script created and tested
  • Node drain tested in dev with PDB verification
  • Recovery runbook documented per fault type
  • Cloud provider IAM roles configured correctly
  • At least one Continuous probe per experiment with stopOnFailure: true
  • Infrastructure faults only run after application faults pass
  • Production infrastructure faults require explicit game day approval

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.