Skip to content

Commit

Permalink
Remove recipe for installing Kafka from source
Browse files Browse the repository at this point in the history
With the 0.8.2 release there’ll be three different ways to build three
different versions of Kafka, and this is just getting out of hand.
There’s too much to support between releases, and I highly doubt that
anyone is actually gonna deploy Kafka from source to production servers.

The `binary` recipe has been renamed to `_install` and is considered an
“internal” recipe, other than that there’s just a lot of code gone, and
there’s a lot more that can be cleaned up.
  • Loading branch information
mthssdrbrg committed Nov 19, 2014
1 parent f9686e6 commit 59d09d8
Show file tree
Hide file tree
Showing 15 changed files with 17 additions and 693 deletions.
59 changes: 0 additions & 59 deletions .kitchen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,62 +89,3 @@ suites:
log_dirs: ['/mnt/kafka-logs-1', '/mnt/kafka-logs-2']
zookeeper_connect: ['localhost:2181']
zookeeper_connection_timeout_ms: 15_000
- name: source-init-style-upstart
run_list:
- recipe[java::default]
- recipe[kafka::default]
excludes:
- centos-6.5
- centos-7.0
- debian-7.4
- fedora-20
attributes:
kafka:
install_method: 'source'
init_style: 'upstart'
version: <%= ENV.fetch('KAFKA_VERSION', '0.8.1.1') %>
checksum: <%= ENV.fetch('KAFKA_CHECKSUM', '""') %>
md5_checksum: <%= ENV.fetch('KAFKA_MD5', '""') %>
broker:
controlled_shutdown_enable: <%= ENV.fetch('KAFKA_CTRL_SHUTDOWN', nil) %>
log_dirs: ['/mnt/kafka-logs-1', '/mnt/kafka-logs-2']
ulimit_file: 128000
zookeeper_connect: ['localhost:2181']
zookeeper_connection_timeout_ms: 15_000
- name: source-init-style-sysv
run_list:
- recipe[java::default]
- recipe[kafka::default]
excludes:
- centos-7.0
attributes:
kafka:
install_method: 'source'
version: <%= ENV.fetch('KAFKA_VERSION', '0.8.1.1') %>
checksum: <%= ENV.fetch('KAFKA_CHECKSUM', '""') %>
md5_checksum: <%= ENV.fetch('KAFKA_MD5', '""') %>
broker:
controlled_shutdown_enable: <%= ENV.fetch('KAFKA_CTRL_SHUTDOWN', nil) %>
log_dirs: ['/mnt/kafka-logs-1', '/mnt/kafka-logs-2']
ulimit_file: 128000
zookeeper_connect: ['localhost:2181']
zookeeper_connection_timeout_ms: 15_000
- name: source-init-style-systemd
run_list:
- recipe[java::default]
- recipe[kafka::default]
includes:
- fedora-20
- centos-7.0
attributes:
kafka:
install_method: 'source'
init_style: 'systemd'
version: <%= ENV.fetch('KAFKA_VERSION', '0.8.1.1') %>
checksum: <%= ENV.fetch('KAFKA_CHECKSUM', '""') %>
md5_checksum: <%= ENV.fetch('KAFKA_MD5', '""') %>
broker:
controlled_shutdown_enable: <%= ENV.fetch('KAFKA_CTRL_SHUTDOWN', nil) %>
log_dirs: ['/mnt/kafka-logs-1', '/mnt/kafka-logs-2']
zookeeper_connect: ['localhost:2181']
zookeeper_connection_timeout_ms: 15_000
4 changes: 0 additions & 4 deletions attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@
# Scala version of Kafka.
default.kafka.scala_version = '2.9.2'

#
# Decides how to install Kafka, valid values are currently :binary and :source.
default.kafka.install_method = :binary

#
# Directory where to install Kafka.
default.kafka.install_dir = '/opt/kafka'
Expand Down
28 changes: 2 additions & 26 deletions libraries/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,7 @@ def kafka_src
end

def kafka_target_path
if kafka_binary_install?
::File.join(node.kafka.build_dir, kafka_base)
else
if kafka_v0_8_0?
::File.join(node.kafka.build_dir, kafka_src, 'target', 'RELEASE', kafka_base)
else
::File.join(node.kafka.build_dir, kafka_src, 'core', 'build', 'distributions', kafka_base)
end
end
::File.join(node.kafka.build_dir, kafka_base)
end

def kafka_jar_path
Expand All @@ -40,37 +32,21 @@ def kafka_download_uri(filename)
end

def kafka_archive_ext
if kafka_v0_8_0? && kafka_binary_install?
if kafka_v0_8_0?
'tar.gz'
else
'tgz'
end
end

def kafka_build_command
if kafka_v0_8_0?
%(./sbt update && ./sbt "++#{node.kafka.scala_version} release-zip")
else
%(./gradlew -PscalaVersion=#{node.kafka.scala_version} releaseTarGz -x signArchives)
end
end

def kafka_v0_8_0?
node.kafka.version == '0.8.0'
end

def kafka_install_method
node.kafka.install_method.to_sym
end

def kafka_init_style
node.kafka.init_style.to_sym
end

def kafka_binary_install?
kafka_install_method == :binary
end

def kafka_init_opts
@kafka_init_opts ||= Hash.new.tap do |opts|
case kafka_init_style
Expand Down
2 changes: 1 addition & 1 deletion recipes/binary.rb → recipes/_install.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#
# Cookbook Name:: kafka
# Recipe:: binary
# Recipe:: _install
#

kafka_tar_gz = [kafka_base, kafka_archive_ext].join('.')
Expand Down
13 changes: 4 additions & 9 deletions recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@
# Recipe:: default
#

case kafka_install_method
when :source, :binary
include_recipe 'kafka::_defaults'
include_recipe 'kafka::_setup'
include_recipe 'kafka::%s' % node.kafka.install_method
include_recipe 'kafka::_configure'
else
Chef::Application.fatal!('Unknown install_method: %s' % node.kafka.install_method.inspect)
end
include_recipe 'kafka::_defaults'
include_recipe 'kafka::_setup'
include_recipe 'kafka::_install'
include_recipe 'kafka::_configure'
35 changes: 0 additions & 35 deletions recipes/source.rb

This file was deleted.

67 changes: 7 additions & 60 deletions spec/recipes/default_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,72 +3,19 @@
require 'spec_helper'

describe 'kafka::default' do
TerminatedExecutionError = Class.new(StandardError)

let :chef_run do
ChefSpec::Runner.new do |node|
node.set[:kafka][:install_method] = install_method
end.converge(described_recipe)
end

shared_examples_for 'a valid install method' do
it 'includes kafka::_setup' do
expect(chef_run).to include_recipe('kafka::_setup')
end

it 'includes kafka::install_method recipe' do
expect(chef_run).to include_recipe(%(kafka::#{install_method}))
end

it 'includes kafka::_configure' do
expect(chef_run).to include_recipe('kafka::_configure')
end
ChefSpec::Runner.new.converge(described_recipe)
end

context 'when node.kafka.install_method equals :source' do
it_behaves_like 'a valid install method' do
let :install_method do
:source
end
end
it 'includes kafka::_setup' do
expect(chef_run).to include_recipe('kafka::_setup')
end

context 'when node.kafka.install_method equals \'source\'' do
it_behaves_like 'a valid install method' do
let :install_method do
'source'
end
end
it 'includes kafka::_install recipe' do
expect(chef_run).to include_recipe('kafka::_install')
end

context 'when node.kafka.install_method equals :binary' do
it_behaves_like 'a valid install method' do
let :install_method do
:binary
end
end
end

context 'when node.kafka.install_method equals \'binary\'' do
it_behaves_like 'a valid install method' do
let :install_method do
'binary'
end
end
end

context 'when node.kafka.install_method is something else' do
let :install_method do
:bork
end

before do
allow(Chef::Application).to receive(:fatal!).and_raise(TerminatedExecutionError)
end

it 'terminates the chef run' do
expect { chef_run.converge(described_recipe) }.to raise_error(TerminatedExecutionError)
expect(Chef::Application).to have_received(:fatal!).with(/Unknown install_method: :bork/).once
end
it 'includes kafka::_configure' do
expect(chef_run).to include_recipe('kafka::_configure')
end
end
7 changes: 3 additions & 4 deletions spec/recipes/binary_spec.rb → spec/recipes/install_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@

require 'spec_helper'

describe 'kafka::binary' do
describe 'kafka::_install' do
let :chef_run do
ChefSpec::Runner.new(step_into: %w(kafka_download kafka_install)) do |node|
node.set[:kafka][:install_method] = :binary
end.converge(described_recipe)
r = ChefSpec::Runner.new(step_into: %w(kafka_download kafka_install))
r.converge(described_recipe)
end

it 'downloads remote binary release of Kafka' do
Expand Down
93 changes: 0 additions & 93 deletions spec/recipes/source_spec.rb

This file was deleted.

Loading

0 comments on commit 59d09d8

Please sign in to comment.