Install pre-commit and use GitHub Actions (#94)

* added pre-commit and code-cleaning

* removed tox and TravisCI
This commit is contained in:
Amit Sagtani
2021-05-05 19:23:45 +05:30
committed by GitHub
parent 70b14956c7
commit d00d6ec69e
43 changed files with 424 additions and 438 deletions

View File

@@ -22,15 +22,17 @@ $ git push
```
## Fix Formatting
You can do this before your first commit but please take a look at the formatting outlined using tox.
Kraken uses [pre-commit](https://pre-commit.com) framework to maintain the code linting and python code styling.
The CI would run the pre-commit check on each pull request.
We encourage our contributors to follow the same pattern, while contributing to the code.
To run:
The pre-commit configuration file is present in the repository `.pre-commit-config.yaml`
It contains the different code styling and linting guide which we use for the application.
```pip install tox ```(if not already installed)
Following command can be used to run the pre-commit:
`pre-commit run --all-files`
```tox```
Fix all spacing, import issues and other formatting issues
If pre-commit is not installed in your system, it can be install with : `pip install pre-commit`
## Squash Commits
If there are mutliple commits, please rebase/squash multiple commits
@@ -50,6 +52,3 @@ Push your rebased commits (you may need to force), then issue your PR.
```
$ git push origin <my-working-branch> --force
```

View File

@@ -1,6 +1,6 @@
### Litmus Scenarios
Kraken consumes [Litmus](https://github.com/litmuschaos/litmus) under the hood for some infrastructure, pod, and node scenarios
Official Litmus documentation and to read more information on specifics of Litmus resources can be found [here](https://docs.litmuschaos.io/docs/next/getstarted/)
@@ -10,32 +10,29 @@ There are 3 custom resources that are created during each Litmus scenario. Below
* ChaosExperiment: A resource to group the configuration parameters of a chaos experiment. ChaosExperiment CRs are created by the operator when experiments are invoked by ChaosEngine.
* ChaosResult : A resource to hold the results of a chaos-experiment. The Chaos-exporter reads the results and exports the metrics into a configured Prometheus server.
### Understanding Litmus Scenarios
### Understanding Litmus Scenarios
To run Litmus scenarios we need to apply 3 different resources/yaml files to our cluster
1. **Chaos experiments** contain the actual chaos details of a scenario
i. This is installed automatically by Kraken (does not need to be specified in kraken scenario configuration)
2. **Service Account**: should be created to allow chaosengine to run experiments in your application namespace. Usually sets just enough permissions to a specific namespace to be able to run the experiment properly
2. **Service Account**: should be created to allow chaosengine to run experiments in your application namespace. Usually sets just enough permissions to a specific namespace to be able to run the experiment properly
i. This can be defined using either a link to a yaml file or a downloaded file in the scenarios folder
3. **Chaos Engine** connects the application instance to a Chaos Experiment. This is where you define the specifics of your scenario; ie: the node or pod name you want to cause chaos within
3. **Chaos Engine** connects the application instance to a Chaos Experiment. This is where you define the specifics of your scenario; ie: the node or pod name you want to cause chaos within
i. This is a downloaded yaml file in the scenarios folder, full list of scenarios can be found [here](https://hub.litmuschaos.io/)
**NOTE**: By default all chaos experiments will be installed based on the version you give in the config file.
**NOTE**: By default all chaos experiments will be installed based on the version you give in the config file.
Adding a new Litmus based scenario is as simple as adding references to 2 new yaml files (the Service Account and Chaos engine files for your scenario ) in the Kraken config.
### Current Scenarios
Following are the start of scenarios for which a chaos scenario config exists today.
Following are the start of scenarios for which a chaos scenario config exists today.
Component | Description | Working
------------------------ | ---------------------------------------------------------------------------------------------------| ------------------------- |
Node CPU Hog | Chaos scenario that hogs up the CPU on a defined node for a specific amount of time | :heavy_check_mark: |

View File

@@ -16,7 +16,7 @@ Following node chaos scenarios are supported:
**NOTE**: node_start_scenario, node_stop_scenario, node_stop_start_scenario, node_termination_scenario, node_reboot_scenario and stop_start_kubelet_scenario are supported only on AWS and GCP as of now.
#### AWS
#### AWS
**NOTE**: For clusters with AWS make sure [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2.html) is installed and properly [configured](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-quickstart.html) using an AWS account
@@ -24,9 +24,9 @@ Following node chaos scenarios are supported:
**NOTE**: For clusters with GCP make sure [GCP CLI](https://cloud.google.com/sdk/docs/install#linux) is installed.
A google service account is required to give proper authentication to GCP for node actions. See [here](https://cloud.google.com/docs/authentication/getting-started) for how to create a service account.
**NOTE**: A user with 'resourcemanager.projects.setIamPolicy' permission is required to grant project-level permissions to the service account.
After creating the service account you'll need to enable the account using the following: ```export GOOGLE_APPLICATION_CREDENTIALS="<serviceaccount.json>"```
#### OPENSTACK
@@ -47,7 +47,7 @@ You will also need to create a service principal and give it the correct access,
To properly run the service principal requires “Azure Active Directory Graph/Application.ReadWrite.OwnedBy” api permission granted and “User Access Administrator”
Before running you'll need to set the following:
Before running you'll need to set the following:
1. Login using ```az login```
2. ```export AZURE_TENANT_ID=<tenant_id>```
@@ -87,15 +87,15 @@ node_scenarios:
label_selector: node-role.kubernetes.io/infra
instance_kill_count: 1
timeout: 120
- actions:
- actions:
- stop_start_helper_node_scenario # node chaos scenario for helper node
instance_kill_count: 1
timeout: 120
instance_kill_count: 1
timeout: 120
helper_node_ip: # ip address of the helper node
service: # check status of the services on the helper node
- haproxy
- dhcpd
- named
ssh_private_key: /root/.ssh/id_rsa # ssh key to access the helper node
cloud_type: openstack
cloud_type: openstack
```

View File

@@ -1,5 +1,5 @@
### Pod Scenarios
Kraken consumes [Powerfulseal](https://github.com/powerfulseal/powerfulseal) under the hood to run the pod scenarios.
Kraken consumes [Powerfulseal](https://github.com/powerfulseal/powerfulseal) under the hood to run the pod scenarios.
#### Pod chaos scenarios

View File

@@ -27,4 +27,4 @@ time_scenarios:
- action: skew_date
object_type: node
label_selector: node-role.kubernetes.io/worker
```
```