Skip to main content

ChaosIQ plugin for the Chaos Toolkit CLI

Project description

ChaosIQ extension for the Chaos Toolkit

Build Status Python versions Has wheel

This is the ChaosIQ extension package for the Chaos Toolkit.

Purpose

The purpose of this package is to communicate with ChaosIQ in order to:

  • Publish experiments
  • Publish executions of these experiments
  • Safely guard the execution via a set of controls

Install

Install this package as any other Python packages:

$ pip install -U chaosiq-cloud

Usage

Once installed, signin, org, publish, enable and disable will be added to the chaos command.

$ chaos
Usage: chaos [OPTIONS] COMMAND [ARGS]...

Options:
  --version                   Show the version and exit.
  --verbose                   Display debug level traces.
  --no-version-check          Do not search for an updated version of the
                              chaostoolkit.
  --change-dir TEXT           Change directory before running experiment.
  --no-log-file               Disable logging to file entirely.
  --log-file TEXT             File path where to write the command's log.
                              [default: chaostoolkit.log]
  --log-format [string|json]  Console logging format: string, json.
  --settings TEXT             Path to the settings file.  [default:
                              ~/.chaostoolkit/settings.yaml]
  --help                      Show this message and exit.

Commands:
  disable   Disable a ChaosIQ feature
  discover  Discover capabilities and experiments.
  enable    Enable a ChaosIQ feature
  info      Display information about the Chaos Toolkit environment.
  init      Initialize a new experiment from discovered capabilities.
  org       Set ChaosIQ organisation
  publish   Publish your experiment's journal to ChaosIQ
  run       Run the experiment loaded from SOURCE, either a local file or a...
  signin    Sign-in with your ChaosIQ credentials
  validate  Validate the experiment at PATH.

Sign-in with ChaosIQ

In order to work, you first need to authenticate with your account on ChaosIQ. First, go there and generate a new token. Copy that token and paste it when asked from the next command:

$ chaos signin
ChaosIQ url [https://console.chaosiq.io]: 
ChaosIQ token: 
Here are your known organizations:
1) yourorg
2) TeamA
3) TeamB
Default organization to publish to: 2
Experiments and executions will be published to organization 'TeamA'
ChaosIQ details saved at ~/.chaostoolkit/settings.yaml

This is now ready to be used.

Change ChaosIQ Organization

ChaosIQ has support for multiple organizations. You can specify which of the organizations that you want the ChaosIQ extension to use by executing the org command:

$ chaos org
Here are your known organizations:
1) yourorg
2) TeamA
3) TeamB
Default organization to publish to: 3
Experiments and executions will be published to organization 'TeamB'
ChaosIQ details saved at ~/.chaostoolkit/settings.yaml

This is now ready to be used.

Publish experiments and executions as you run

Once this extension is installed, it starts transmitting the experiments and their executions to the ChaosIQ in your selected organization.

$ chaos run test.json
[2019-09-25 14:42:34 INFO] Validating the experiment's syntax
[2019-09-25 14:42:34 INFO] Experiment looks valid
[2019-09-25 14:42:34 INFO] Running experiment: EC2 instances are self-healing
[2019-09-25 14:42:35 INFO] Execution available at https://console.chaosiq.io/TeamB/executions/f2133988-a6c0-4c48-ac29-c167cea078c5
[2019-09-25 14:42:35 INFO] Steady state hypothesis: EC2 instance self-heals
[2019-09-25 14:42:36 INFO] Probe: there-should-be-one-running-instance
[2019-09-25 14:42:39 INFO] Steady state hypothesis is met!
[2019-09-25 14:42:40 INFO] Action: stopping-instance-now
[2019-09-25 14:42:41 INFO] Pausing after activity for 5s...
[2019-09-25 14:42:47 INFO] Steady state hypothesis: EC2 instance self-heals
[2019-09-25 14:42:48 INFO] Probe: there-should-be-one-running-instance
[2019-09-25 14:42:50 CRITICAL] Steady state probe 'there-should-be-one-running-instance' is not in the given tolerance so failing this experiment
[2019-09-25 14:42:50 INFO] Let's rollback...
[2019-09-25 14:42:50 INFO] Rollback: starting-instance-again
[2019-09-25 14:42:51 INFO] Pausing before next activity for 15s...
[2019-09-25 14:43:06 INFO] Action: starting-instance-again
[2019-09-25 14:43:08 INFO] Experiment ended with status: deviated
[2019-09-25 14:43:08 INFO] The steady-state has deviated, a weakness may have been discovered

Publish existing execution

The publish command enables you to manually push your experimental findings, typically recorded in the journal.json, to your ChaosIQ organization.

Disable safe guards checking

During development time of your experiment, you may wish to disable checking for safeguards as they can slow your work down. They aren't always relevant either. To disable the extension from requesting if the execution is allowed to carry on:

$ chaos disable safeguards

Obviously, run the mirroring command to enable them back:

$ chaos enable safeguards

Disable publishing experiments and executions

If you need to disable publishing for a little whie

$ chaos disable publish

Note, when you disable publishing, you essentialy disable the entire extension.

Obviously, run the mirroring command to enable publishing again:

$ chaos enable publish

Contribute

Contributors to this project are welcome as this is an open-source effort that seeks discussions and continuous improvement.

From a code perspective, if you wish to contribute, you will need to run a Python 3.5+ environment. Then, fork this repository and submit a PR. The project cares for code readability and checks the code style to match best practices defined in PEP8. Please also make sure you provide tests whenever you submit a PR so we keep the code reliable.

Develop

If you wish to develop on this project, make sure to install the development dependencies. But first, create a virtual environment and then install those dependencies.

$ pip install -r requirements-dev.txt -r requirements.txt

Then, point your environment to this directory:

$ pip install -e .

Now, you can edit the files and they will be automatically be seen by your environment, even when running from the chaos command locally.

Don't forget to run the linter regularly:

$ pylama chaoscloud

Test

To run the tests for the project execute the following:

$ pytest

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

chaosiq-cloud-0.4.0.tar.gz (18.1 kB view hashes)

Uploaded Source

Built Distribution

chaosiq_cloud-0.4.0-py2.py3-none-any.whl (21.2 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page