-
Notifications
You must be signed in to change notification settings - Fork 17
/
fail.js
61 lines (53 loc) · 1.93 KB
/
fail.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
'use strict'
let cli = require('heroku-cli-util')
let co = require('co')
let withCluster = require('../lib/clusters').withCluster
let request = require('../lib/clusters').request
const VERSION = 'v0'
function * fail (context, heroku) {
yield withCluster(heroku, context.app, context.args.CLUSTER, function * (addon) {
yield cli.confirmApp(context.app, context.flags.confirm,
`This command will affect the cluster: ${addon.name}, which is on ${context.app}\n\nThis command will forcibly terminate nodes in your cluster at random.\nYou should only run this command in controlled testing scenarios.`)
let response = yield cli.action('Triggering failure', co(function * () {
return yield request(heroku, {
method: 'POST',
body: {
catastrophic: context.flags.catastrophic,
zookeeper: context.flags.zookeeper
},
path: `/data/kafka/${VERSION}/clusters/${addon.id}/induce-failure`
})
}))
cli.log(response.message)
})
}
module.exports = {
topic: 'kafka',
command: 'fail',
description: 'triggers failure on one node in the cluster',
help: `
Triggers failure on one Kafka broker in the cluster by stopping the underlying
instance and allowing Heroku automation to recover it.
Examples:
$ heroku kafka:fail
$ heroku kafka:fail kafka-aerodynamic-32763
`,
needsApp: true,
needsAuth: true,
args: [
{ name: 'CLUSTER', optional: true }
],
flags: [
{ name: 'catastrophic',
description: 'terminate the underlying instance instead and allow automation to replace it',
hasValue: false },
{ name: 'zookeeper',
description: 'induce failure on one of the cluter\'s Zookeeper nodes instead',
hasValue: false },
{ name: 'confirm',
description: 'pass the app name to skip the manual confirmation prompt',
hasValue: true,
required: false }
],
run: cli.command({preauth: true}, co.wrap(fail))
}