> For the complete documentation index, see [llms.txt](https://developer.harness.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.harness.io/resilience-testing/chaos-testing/chaos-faults/cloud-foundry.md). Agents can also search and read this documentation through its [MCP server](https://developer.harness.io/~gitbook/mcp).

# Cloud Foundry

Cloud Foundry chaos faults that stop apps, kill app instances, inject JVM faults, and disrupt app network traffic on TAS, PCF, and open-source Cloud Foundry.

Cloud Foundry faults disrupt the running state of an app, the JVM inside an app instance, or the network between an app and its dependencies. Use them to test platform self-healing, app timeouts, retries, and fallbacks, and the behavior of consumers on Tanzu Application Service (TAS), Pivotal Cloud Foundry (PCF), or open-source Cloud Foundry.

***

## Before you begin

* **Linux chaos infrastructure:** A Linux chaos infrastructure installed in one of the [deployment models](#deployment-models) below. Go to [Linux infrastructure](https://developer.harness.io/resilience-testing/chaos-testing/infrastructure/linux.md) to install it.
* **Credentials:** The Cloud Foundry credentials, and the BOSH credentials for instance-level and JVM faults, are configured on the chaos infrastructure host. Go to [Cloud Foundry fault authentication](https://developer.harness.io/resilience-testing/chaos-testing/chaos-faults/cloud-foundry/authentication.md) to set them.
* **Permissions:** The Cloud Foundry user and the BOSH client hold the roles and scopes the faults need. Go to [Cloud Foundry fault permissions](https://developer.harness.io/resilience-testing/chaos-testing/chaos-faults/cloud-foundry/permissions.md) to check them.

***

## How Cloud Foundry faults run

Two components run in your Cloud Foundry environment:

* **Linux chaos infrastructure:** A `systemd` service that claims fault tasks from the Harness control plane, runs resilience probes, and reports results back.
* **Cloud Foundry fault injector:** A short-lived process that the Linux chaos infrastructure launches for each fault. It calls the Cloud Foundry Cloud Controller API and the `containerd` container runtime API to create the fault condition.

When an experiment runs, the Linux chaos infrastructure fetches the fault task, parses the app and fault inputs, launches the fault injector with those inputs, and relays the results to the control plane when the fault ends.

![Harness control plane creates a Cloud Foundry fault task; the Linux chaos infrastructure in the Cloud Foundry environment claims it, launches the fault injector, and relays logs and results back](https://3217710372-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRmV5EkLS9r45VPaoUnJZ%2Fuploads%2Fgit-blob-c7eea9ae9d62f4c447d84288adbd6c04ef412063%2Fcf-control-plane-2.png?alt=media)

The faults fall into three groups, by what they act on:

| Group                    | What it does                                                         | Faults                                           |
| ------------------------ | -------------------------------------------------------------------- | ------------------------------------------------ |
| Cloud Foundry API faults | Change app state through the Cloud Controller API only               | CF app stop, CF app route unmap                  |
| App instance faults      | Act on the containers of individual app instances in the Diego cells | CF app container kill, the CF app network faults |
| App process faults       | Act on the JVM process inside an app instance                        | The CF app JVM faults                            |

***

## Deployment models

Choose the model that fits your network. The `deploymentModel` tunable on instance-level and JVM faults tells the fault which one you use.

### Cell model (`model-1`)

The Linux chaos infrastructure and the fault injector run as a `systemd` service on a Diego cell. Faults reach only the app instances on that cell, which keeps the blast radius small.

![Deployment model 1: the Linux chaos infrastructure runs on a Diego cell and calls the Cloud Foundry API and the container runtime API of that cell](https://3217710372-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRmV5EkLS9r45VPaoUnJZ%2Fuploads%2Fgit-blob-d7af5733fb6930789572f6359b865fbf82bacee2%2Fcf-deployment-model-3.png?alt=media)

### Jumpbox model (`model-2`)

The Linux chaos infrastructure runs on the Tanzu Ops Manager (jumpbox) VM and reaches the Diego cells over [BOSH SSH](https://community.pivotal.io/s/article/How-to-Run-Bash-Commands-via-BOSH?language=en_US). Faults can target app instances on several Diego cells. Use this model when the Diego cells sit in a private network with no outbound connectivity. App instance and app process faults need the BOSH credentials in this model.

![Deployment model 2: the Linux chaos infrastructure runs on Tanzu Ops Manager and runs commands on the Diego cells over BOSH SSH](https://3217710372-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRmV5EkLS9r45VPaoUnJZ%2Fuploads%2Fgit-blob-5b12ddd1c527cdf2896bf0c03b76de401af03ec5%2Fcf-deployment-tanzu-4.png?alt=media)

### Sidecar model

The chaos infrastructure runs as a native Cloud Foundry app, and a chaos sidecar process runs in each target app instance. The app claims fault tasks from the control plane, runs Cloud Foundry API faults itself, and exposes app process tasks that each sidecar fetches and runs inside its own instance.

This model needs no root privileges, so it cannot run app instance faults. Go to the [sidecar-based chaos approach](https://hce-docs.github.io/platform-wise-chaos-info/PCF/sidecar-approach-for-jvm-chaos-in-pcf.html) to set it up.

![Sidecar model: a chaos infrastructure app in one Diego cell exposes fault tasks that chaos sidecar processes in other app instances poll and run](https://3217710372-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRmV5EkLS9r45VPaoUnJZ%2Fuploads%2Fgit-blob-219af655322106cda48ba064f09fee5ca85c533b%2Fcf-sidecar.png?alt=media)

Go to [Cloud Foundry fault permissions](https://developer.harness.io/resilience-testing/chaos-testing/chaos-faults/cloud-foundry/permissions.md#deployment-model-requirements) for the connectivity and access each model needs.

***

## Supported environments

Cloud Foundry faults run on TAS, PCF, and open-source Cloud Foundry deployments managed by BOSH. A fault page lists any environment below that it does not support.

| Environment                                                                               | Support status                          |
| ----------------------------------------------------------------------------------------- | --------------------------------------- |
| TAS, PCF, or open-source Cloud Foundry with `containerd` as the default container runtime | Supported                               |
| Cloud Foundry versions that do not use `containerd` as the default container runtime      | Not supported                           |
| Java apps                                                                                 | All faults                              |
| Non-Java apps                                                                             | All faults except the CF app JVM faults |

***

## Faults

| Fault                                                                                                                                                  | What it does                                                       | Failure type  | Reversible |
| ------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------- | ---------- |
| [CF app container kill](https://developer.harness.io/resilience-testing/chaos-testing/chaos-faults/cloud-foundry/cf-app-container-kill.md)             | Kills the containers of app instances                              | State         | Yes        |
| [CF app JVM CPU stress](https://developer.harness.io/resilience-testing/chaos-testing/chaos-faults/cloud-foundry/cf-app-jvm-cpu-stress.md)             | Consumes CPU inside the JVM of an app instance                     | Resource      | Yes        |
| [CF app JVM memory stress](https://developer.harness.io/resilience-testing/chaos-testing/chaos-faults/cloud-foundry/cf-app-jvm-memory-stress.md)       | Consumes heap or non-heap memory inside the JVM of an app instance | Resource      | Yes        |
| [CF app JVM method exception](https://developer.harness.io/resilience-testing/chaos-testing/chaos-faults/cloud-foundry/cf-app-jvm-method-exception.md) | Throws an exception from a Java method                             | Application   | Yes        |
| [CF app JVM method latency](https://developer.harness.io/resilience-testing/chaos-testing/chaos-faults/cloud-foundry/cf-app-jvm-method-latency.md)     | Adds latency to every call of a Java method                        | Application   | Yes        |
| [CF app JVM modify return](https://developer.harness.io/resilience-testing/chaos-testing/chaos-faults/cloud-foundry/cf-app-jvm-modify-return.md)       | Changes the value a Java method returns                            | Application   | Yes        |
| [CF app JVM trigger GC](https://developer.harness.io/resilience-testing/chaos-testing/chaos-faults/cloud-foundry/cf-app-jvm-trigger-gc.md)             | Forces a full garbage collection in the JVM of an app instance     | Application   | Yes        |
| [CF app network corruption](https://developer.harness.io/resilience-testing/chaos-testing/chaos-faults/cloud-foundry/cf-app-network-corruption.md)     | Corrupts a percentage of outbound packets from app instances       | Network       | Yes        |
| [CF app network duplication](https://developer.harness.io/resilience-testing/chaos-testing/chaos-faults/cloud-foundry/cf-app-network-duplication.md)   | Duplicates a percentage of outbound packets from app instances     | Network       | Yes        |
| [CF app network latency](https://developer.harness.io/resilience-testing/chaos-testing/chaos-faults/cloud-foundry/cf-app-network-latency.md)           | Adds latency to outbound traffic from app instances                | Network       | Yes        |
| [CF app network loss](https://developer.harness.io/resilience-testing/chaos-testing/chaos-faults/cloud-foundry/cf-app-network-loss.md)                 | Drops a percentage of outbound packets from app instances          | Network       | Yes        |
| [CF app route unmap](https://developer.harness.io/resilience-testing/chaos-testing/chaos-faults/cloud-foundry/cf-app-route-unmap.md)                   | Unmaps a route from an app, then maps it again                     | Configuration | Yes        |
| [CF app stop](https://developer.harness.io/resilience-testing/chaos-testing/chaos-faults/cloud-foundry/cf-app-stop.md)                                 | Stops an app, then starts it again                                 | State         | Yes        |

***

## Troubleshooting

<details>

<summary>A Cloud Foundry fault fails with an authentication error</summary>

Check that `CF_API_ENDPOINT`, `UAA_SERVER_ENDPOINT`, `CF_USERNAME`, and `CF_PASSWORD` are set in `/etc/linux-chaos-infrastructure/cf.env` on the chaos infrastructure host, and that the user can sign in with `cf login`. Go to [Cloud Foundry fault authentication](https://developer.harness.io/resilience-testing/chaos-testing/chaos-faults/cloud-foundry/authentication.md) to check where each value is read from.

</details>

<details>

<summary>A Cloud Foundry fault cannot find the app</summary>

The `organization`, `space`, and `app` tunables are case-sensitive and must match Cloud Foundry exactly. Run `cf target -o <organization> -s <space>` and then `cf app <app>` on the chaos infrastructure host, signed in as the same user, to confirm the user can see the app.

</details>

<details>

<summary>An app instance or JVM fault fails to reach the Diego cell</summary>

With `deploymentModel` set to `model-2`, the fault reaches the Diego cell over BOSH SSH. Check that the `BOSH_*` credentials are set, that `boshDeployment` names the deployment that runs the Diego cells (run `bosh deployments` to list them), and that the BOSH client has the `bosh.ssh` or `bosh.admin` scope.

</details>

***

## Next steps

* Go to [Cloud Foundry fault permissions](https://developer.harness.io/resilience-testing/chaos-testing/chaos-faults/cloud-foundry/permissions.md) to grant the Cloud Foundry roles and BOSH scopes.
* Go to [Cloud Foundry fault authentication](https://developer.harness.io/resilience-testing/chaos-testing/chaos-faults/cloud-foundry/authentication.md) to configure credentials on the chaos infrastructure host.
* Go to [Linux](https://developer.harness.io/resilience-testing/chaos-testing/chaos-faults/linux.md) to run host-level faults on the VMs that run Cloud Foundry.

{% @harness-feedback/feedback %}
