Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Features #25

Open
wants to merge 30 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
cde1b31
Added the ability to pause a process for a period of time.
mattiekat Jul 6, 2018
bf9b170
First attempt at v0.11.0
mattiekat Jul 6, 2018
8ef4ebb
Create .gitattributes
mattiekat Jul 9, 2018
054379a
Added file to link src to gopath for development purposes.
mattiekat Jul 9, 2018
2fafae9
Revert "First attempt at v0.11.0"
mattiekat Jul 9, 2018
b8a6c75
Updated docs to include PauseProcess.
mattiekat Jul 10, 2018
51d13c7
Update api.md
mattiekat Jul 10, 2018
43a14bd
Escaped '*'
mattiekat Jul 12, 2018
350cf1f
Fixed issue #21
mattiekat Jul 12, 2018
ef1a723
Added new functions to Control Network
mattiekat Jul 12, 2018
6a83208
Updated documentation
mattiekat Jul 12, 2018
bdcdd87
Fixed logic error in control network code
mattiekat Jul 12, 2018
f6c3b1a
Fixed issue where duplicate commands would cause others to be cancele…
mattiekat Jul 12, 2018
de699fa
Updated fill disk to accept a timeout.
mattiekat Jul 12, 2018
4b52b03
Updates
mattiekat Jul 13, 2018
0d45fcf
Added BlockDNSTask
mattiekat Jul 16, 2018
4d148d9
Updated docs and minor fix
mattiekat Jul 16, 2018
9e8c4f1
Added blackhole task for testing
mattiekat Jul 27, 2018
e7e362c
Fixed issue with blackhole iptables call
mattiekat Jul 27, 2018
8aea830
Updated docs
mattiekat Jul 27, 2018
84829ad
Fixed stupid error.
mattiekat Jul 27, 2018
83b8a01
Updates to blackhole and docs.
mattiekat Aug 13, 2018
1951ccf
Updated blackhole to make a distinction between src and dst hosts.
mattiekat Aug 13, 2018
a4c0452
Renamed Blackhole to TargetedBlocker
mattiekat Aug 13, 2018
f6bad9d
not required to use two chains
h0nIg Jan 30, 2019
c68ed29
add capability to specify outgoing destinations for ControlNetwork
h0nIg Jan 31, 2019
5d1472e
fix bug
h0nIg Jan 31, 2019
2e8fbdf
added controlnet target documentation
h0nIg Mar 8, 2019
794cbda
reset all interfaces in case of error to avoid subsequent errors caus…
h0nIg Mar 15, 2019
8f5237d
Rebranded to Turbulence++
mattiekat Apr 9, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text eol=lf
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Turbulence
# Turbulence++

Turbulence release is used for injecting different failure scenarios into a BOSH deployed system. Currently the following scenarios are supported:
Turbulence++ release is used for injecting different failure scenarios into a BOSH deployed system. Currently the following scenarios are supported:

- VM termination on BOSH supported IaaSes
- impose CPU/RAM/IO load
Expand All @@ -16,8 +16,8 @@ Agent job is a daemon that periodically retrieves instructions from the API serv
Next steps:

- [Configuration doc](docs/config.md) on how to configure API server and agents
- [API doc](docs/api.md) on how to use Turbulence
- [API client doc](docs/client.md) on how to use Turbulence GO client
- [API doc](docs/api.md) on how to use Turbulence++
- [API client doc](docs/client.md) on how to use Turbulence++ GO client
- [Development doc](docs/dev.md) on how to contribute

--
Expand Down
103 changes: 101 additions & 2 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ Available selector rules:
- set `Values` (array of strings; optional)
- set `Limit` (string; optional)

Limits default to 100%. Name defaults to '*' and wildcard matches are supported.
Limits default to 100%. Name defaults to '\*' and wildcard matches are supported.

```json
{
Expand Down Expand Up @@ -208,6 +208,25 @@ Example:
}
```

### Pause Process

Pause one or more process on the VM associated with an instance.

Configuration:

- set `ProcessName`(string) to a pattern used with `pkill`
- set `timeout` (string) to how long the process should remain paused. A valid timeout is required.

Example:

```json
{
"Type": "PauseProcess",
"ProcessName": "sshd",
"Timeout": "10m" // Times may be suffixed with s,m,h,d,y
}
```

### Stress

Stresses different subsystems on the VM associated with an instance.
Expand Down Expand Up @@ -263,6 +282,58 @@ Example:
}
```

### TargetedBlocker

Drops incoming and or outgoing traffic from one or more VMs. It is able to target specific IPs and Ports to simulate the failure of specific services.

Currently iptables is used for dropping packets from INPUT and OUTPUT chains.

Target parameters:

- set `Direction` (string; required) to the direction of traffic to drop, can be either "INPUT", "OUTPUT", or "FORWARD". If you are targeting diego-cells, then you will probably want "FORWARD".
- set `SrcHost` (string) to either an IPv4 address such as "192.168.1.50" or with a mask such as "192.168.0.0/24", or to a domain name which will be resolved into (possibly multiple) IPs such as "example.com" using the dig command. If no host is specified, then all source hosts will be impacted.
- set `DstHost` (string) to either an IPv4 address such as "192.168.1.50" or with a mask such as "192.168.0.0/24", or to a domain name which will be resolved into (possibly multiple) IPs such as "example.com" using the dig command. If no host is specified, then all destination hosts will be impacted.
- set `Protocol` (string) to the protocol to drop traffic on, can be either "udp", "tcp", "icmp", or "all". Defaults to being unspecified.
- set `DstPorts` (string) to the destination port to drop. This can be either a single port such as "8080" or a range such as "1503:1520". If blank, all destination ports will be dropped.
- set `SrcPorts` (string) to the source ports to drop. This can be either a single port such as "8080" or a range such as "1503:1520". If blank, all source ports will be dropped.

*Note*: at least one of `SrcHost`, `DstHost`, `DstPorts`, or `SrcPorts` must be specified.

Example:

```json
{
"Type": "TargetedBlocker",
"Timeout": "10m", // Times may be suffixed with ms,s,m,h
"Targets": [{
"DstHost": "1.1.1.1",
"Direction": "INPUT",
"DstPorts": "53"
},{
"DstHost": "google.com",
"Direction": "FORWARD",
"Protocol": "tcp",
"DstPorts": "80"
}]
}
```


### Block DNS

Causes all outgoing DNS packets to be dropped.

Currently iptables is used for dropping packets going out on tcp or udp port 53.

Example:

```json
{
"Type": "BlockDNS",
"Timeout": "10m" // Times may be suffixed with ms,s,m,h
}
```

### Control Network

Controls network quality on the VM associated with an instance. Does not affect `lo0`.
Expand All @@ -274,10 +345,29 @@ One or both of the following configurations must be selected:
- packet delay
- set `Delay` (string; required). Must be suffixed with `ms`.
- set `DelayVariation` (string; optional). Must be suffixed with `ms`. Default is `10ms`.
- if `DelayVariation >= 0.5*Delay`, then packet reordering may occur.

- packet loss
- set `Loss` (string; required). Must be suffixed with `%`.
- set `LossCorrelation` (string; optional). Must be suffixed with `%`. Default is `75%`.

- packet duplication
- set `Duplication` (string; required). Must be suffixed with `%`.

- packet corruption
- set `Corruption` (string; required). Must be suffixed with `%`.

- packet reordering
- set `Reorder` (string; required). Must be suffixed with `%`.
- set `ReorderCorrelation` (string; optional). Must be suffixed with `%`. Default is `50%`.
- if the `Delay` is less than the inter-packet arrival time, then no reordering will be observed.

- bandwidth limiting
- set `Bandwidth` (string; required). Must be suffixed with one of `kbps`, `mbps` or `gbps`.
- bandwidth limiting must be used without any other effects.

In addition it is possible to apply a destination filter:
- set `Targets` (array, optional). Must include either `DstHost` or `DstPort`

Example:

Expand All @@ -286,7 +376,14 @@ Example:
"Type": "ControlNet",
"Timeout": "10m", // Times may be suffixed with ms,s,m,h

"Delay": "50ms"
"Delay": "50ms",

"Targets": [
{
"DstHost": "1.2.3.4",
"DstHost": "443"
}
]
}
```

Expand All @@ -300,12 +397,14 @@ One of the following configurations must be selected:
- set `Ephemeral` (bool) to fill up /var/vcap/data
- set `Temporary` (bool) to fill up /tmp
- by default uses root disk
- if multiple are selected, the first one in the above order will be used.

Example:

```json
{
"Type": "FillDisk",
"Timeout": "10m", // Times may be suffixed with ms,s,m,h
"Persistent": true
}
```
Expand Down
2 changes: 0 additions & 2 deletions docs/dev.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ Run `./update-deps` to update `github.com/cppforlife/turbulence` package depende
- lock up whole machine
- remount disk as readonly
- corrupt disks
- pause a process
- restrict X% bandw

https://www.kernel.org/doc/Documentation/sysrq.txt might be useful...
http://blog.hut8labs.com/gorillas-before-monkeys.html
Expand Down
9 changes: 9 additions & 0 deletions src/github.com/cppforlife/turbulence/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ func (a Agent) buildAgentTask(task tasks.Task) (agentTask, error) {
t = tasks.NewKillProcessTask(monitClient, a.cmdRunner, opts, a.logger)
}

case tasks.PauseProcessOptions:
t = tasks.NewPauseProcessTask(a.cmdRunner, opts, a.logger)

case tasks.StressOptions:
t = tasks.NewStressTask(a.cmdRunner, opts, a.logger)

Expand All @@ -155,6 +158,12 @@ func (a Agent) buildAgentTask(task tasks.Task) (agentTask, error) {
case tasks.FirewallOptions:
t = tasks.NewFirewallTask(a.cmdRunner, opts, a.agentConfig.AllowedOutputDests(), a.logger)

case tasks.TargetedBlockerOptions:
t = tasks.NewTargetedBlockerTask(a.cmdRunner, opts, a.logger)

case tasks.BlockDNSOptions:
t = tasks.NewBlockDNSTask(a.cmdRunner, opts, a.logger)

case tasks.FillDiskOptions:
t = tasks.NewFillDiskTask(a.cmdRunner, opts, a.logger)

Expand Down
74 changes: 74 additions & 0 deletions src/github.com/cppforlife/turbulence/tasks/block_dns_task.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
package tasks

import (
"strings"

bosherr "github.com/cloudfoundry/bosh-utils/errors"
boshlog "github.com/cloudfoundry/bosh-utils/logger"
boshsys "github.com/cloudfoundry/bosh-utils/system"
)

type BlockDNSOptions struct {
Type string
Timeout string // Times may be suffixed with ms,s,m,h
}

func (BlockDNSOptions) _private() {}

type BlockDNSTask struct {
cmdRunner boshsys.CmdRunner
opts BlockDNSOptions
}

func NewBlockDNSTask(
cmdRunner boshsys.CmdRunner,
opts BlockDNSOptions,
_ boshlog.Logger,
) BlockDNSTask {
return BlockDNSTask{cmdRunner, opts}
}

func (t BlockDNSTask) Execute(stopCh chan struct{}) error {
timeoutCh, err := NewOptionalTimeoutCh(t.opts.Timeout)
if err != nil {
return err
}

rules := t.rules()

for _, r := range rules {
err := t.iptables("-A", r)
if err != nil {
return err
}
}

select {
case <-timeoutCh:
case <-stopCh:
}

for _, r := range rules {
err := t.iptables("-D", r)
if err != nil {
return err
}
}

return nil
}

func (t BlockDNSTask) rules() []string {
return []string{ "OUTPUT -p tcp --destination-port 53 -j DROP", "OUTPUT -p udp --destination-port 53 -j DROP" }
}

func (t BlockDNSTask) iptables(action, rule string) error {
args := append([]string{action}, strings.Split(rule, " ")...)

_, _, _, err := t.cmdRunner.RunCommand("iptables", args...)
if err != nil {
return bosherr.WrapError(err, "Shelling out to iptables")
}

return nil
}
Loading