ChaosIQ plugin for the Chaos Toolkit CLI
Project description
ChaosIQ extension for the Chaos Toolkit
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
, disable
, team
and verify
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
team Set ChaosIQ team
validate Validate the experiment at PATH.
verify Run the verification loaded from SOURCE, either a local file or...
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 while:
$ 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
Run a system verification
A system verification is a chaos experiment with an extension block added such as the following:
...
"extensions": [
{
"name": "chaosiq",
"verification": {
"id": "SOME_GUID",
"warm-up-duration": 2,
"frequency-of-measurement": 2,
"duration-of-conditions": 10,
"cool-down-duration": 2
}
}
],
...
Typically you would create a verification in your ChaosIQ console. You can execute a verification in exactly the same way as the chaos run
default command in the Chaos Toolkit, but instead of chaos run
you will use chaos verify
:
$ chaos verify my-excellent-verification.json
As with Chaos Toolkit experiments, system verifications may be specified in JSON or YAML formats.
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
Release
In order to release this package, you must first bump its version in
chaoscloud/__init__.py
as well as the CHANGELOG. Commit and push these
changes. Then run the followings:
$ git tag VERSION
$ git push origin VERSION
where VERSION
is the semantic version you set in chaoscloud/__init__.py
.
Once the tag was built, it should have released the package on Pypi.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for chaosiq_cloud-0.8.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0be4f8da0ff9401ab9aa1a092e08296d407d85e998b040f236e7f686078a4d9d |
|
MD5 | 85ae04d94c3de6f466754145e0d58a5b |
|
BLAKE2b-256 | 64e7f2c6a8116719e0250aba6ae7a8abc5602f9240a24a134db087572e23bf6e |