Skip to main content

Use CE with Feature Flags

You can add chaos experiments to Harness Feature Flags (FF) pipelines as part of the process to control release of new software. An FF pipeline runs every time a feature flag changes, and lets you specify actions to take before the flag change takes effect. For example, you might want to have an approval step for all flag changes, or run a chaos experiment as part of the pipeline.

When you add a chaos experiment as a step in an FF pipeline, the experiment runs as part of that pipeline whenever you change a feature flag. For example, if you put a new feature behind a feature flag, you might want to run a chaos experiment on the target application affected by the new code. In this way, you can see how the application responds to chaos faults before changing the flag to release the new feature to users.

For more information, see:

Add a chaos experiment to an FF pipeline

Pipelines are organized into stages, each of which handles a major segment of the pipeline process. There are several types of stages available, and you can add chaos experiments as steps in these three stage types:

  • Feature Flag
  • Deploy
  • Custom Stage
note

Harness recommends that when you add a chaos step to an FF pipeline, you also add a subsequent step that disables the feature flag if the chaos step fails. This way, software is not released if the chaos experiment fails.

To add a chaos experiment as a step in your FF pipeline:

  1. In Harness, select Feature Flags > Pipelines, and then select the pipeline where you want to add a chaos experiment.

  2. In the selected pipeline, select Add Stage, and then select a stage type.

    Chaos steps are available for Feature Flag, Deploy, and Custom Stage types.

    Select a stage screen with Feature Flag, Deploy, and Custom Stage highlighted

  3. Enter a Stage Name (and Deployment Type if applicable), and then select Set Up Stage.

  4. With the stage you want selected, select Add Step > Add Step.

    Add step icon with stage selected

    The Step Library appears.

    The Step Library showing a few of many available steps

  5. Scroll down the list to find the Chaos step icon, and then select it.

    Chaos step icon

  6. In the Configure Chaos Experiment screen, enter a Name for this step.

  7. Select Select Chaos Experiment to see the chaos experiments you can add to this stage.

    Select an existing experiment screen grid of experiments and one experiment selected.

    When you select an experiment, the experiment's last resilience score, a preview of the experiment, and its chaos faults, are displayed.

  8. (Optional) On this screen you can:

    • Select New Experiment to create a new experiment in Chaos Studio.
    • Select Edit in Chaos Studio to edit a selected experiment.

    Selecting these options takes you to Chaos Studio without saving your work.

  9. Select the experiment you want to run in this step, and then select Add to Pipeline.

  10. Back in Configure Chaos Experiment, enter the Expected Resilience Score for this experiment.

    • If the resilience score is not met, this chaos step fails and the stage failure strategy is initiated.
    • We recommend you add another step in the pipeline that disables the flag if the chaos step fails.

    For more information, go to Analyze chaos experiments.

  11. (Optional) Expand Optional Configuration, and enter an assertion (you can enter a fixed value, an expression, or a runtime input).

  12. (Optional) Select the Advanced tab to configure more settings.

    For more information on these settings, go to Harness pipelines.

  13. Select Apply Changes to save this step in the pipeline, and then select Save to save changes to the pipeline.

What happens when the FF pipeline runs with a chaos step

When a flag change triggers the FF pipeline:

  • The chaos step you added to the pipeline triggers the experiment to run on the target application.

  • The Chaos Experiments page (Chaos > Chaos Experiments) records the experiment run as part of a pipeline, and you can select the experiment to view its execution.

  • In the FF pipeline, if the chaos step (the experiment) fails, you can select the failed step to see the log, which includes the resilience score obtained and how many chaos probes passed or failed.

    • You can select View Detailed Execution to go to the experiment's execution page in CE.
  • Based on the experiment's success or failure, you can decide whether to enable the flag change to show or hide the feature in the target environment.