From 2278811fd74839e04e79a15fe0eccb3f4a276c4c Mon Sep 17 00:00:00 2001 From: Tom Crayford Date: Tue, 14 Feb 2017 16:11:49 +0000 Subject: [PATCH] catch 400 in kafka consumer group creation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit this 400 is because kafka consumer group creation doesn't need to happen on clusters that have enough credentials to use any consumer group. We don't need to error here sample output: ``` $ heroku kafka:consumer-groups:create greetings; echo $? Creating consumer group greetings... done ▸ kafka-REDACTED-36649 does not need consumer groups managed explicitly, so this command does nothing 0 ``` --- commands/consumer_groups_create.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/commands/consumer_groups_create.js b/commands/consumer_groups_create.js index 4968e1f..e85832e 100644 --- a/commands/consumer_groups_create.js +++ b/commands/consumer_groups_create.js @@ -13,6 +13,7 @@ function * createConsumerGroup (context, heroku) { if (context.args.CLUSTER) { msg += ` on ${context.args.CLUSTER}` } + var created = true yield cli.action(msg, co(function * () { return yield request(heroku, { @@ -23,10 +24,19 @@ function * createConsumerGroup (context, heroku) { } }, path: `/data/kafka/${VERSION}/clusters/${addon.id}/consumer_groups` + }).catch(err => { + if (err.statusCode === 400 && err.body.message === 'this command is not required or enabled on dedicated clusters') { + created = false + cli.warn(`${cli.color.addon(addon.name)} does not need consumer groups managed explicitly, so this command does nothing`) + } else { + throw err + } }) })) - cli.log(`Use \`heroku kafka:consumer-groups:info ${context.args.CONSUMER_GROUP}\` to monitor your consumer group.`) + if (created === true) { + cli.log(`Use \`heroku kafka:consumer-groups:info ${context.args.CONSUMER_GROUP}\` to monitor your consumer group.`) + } }) }