Skip to content

Commit 179c455

Browse files
authored
Merge pull request #344 from caskdata/feature/remove-hdp-version-attrs
Feature/remove hdp version attrs
2 parents c85e60c + e14b89a commit 179c455

File tree

3 files changed

+23
-50
lines changed

3 files changed

+23
-50
lines changed

attributes/default.rb

Lines changed: 3 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -99,54 +99,6 @@
9999
end
100100

101101
# MapReduce settings
102-
full_version =
103-
case node['hadoop']['distribution_version']
104-
when '2.2.0.0'
105-
'2.2.0.0-2041'
106-
when '2.2.1.0'
107-
'2.2.1.0-2340'
108-
when '2.2.4.2'
109-
'2.2.4.2-2'
110-
when '2.2.4.4'
111-
'2.2.4.4-16'
112-
when '2.2.6.0'
113-
'2.2.6.0-2800'
114-
when '2.2.6.3'
115-
'2.2.6.3-1'
116-
when '2.2.8.0'
117-
'2.2.8.0-3150'
118-
when '2.2.9.0'
119-
'2.2.9.0-3393'
120-
when '2.3.0.0'
121-
'2.3.0.0-2557'
122-
when '2.3.2.0'
123-
'2.3.2.0-2950'
124-
when '2.3.4.0'
125-
'2.3.4.0-3485'
126-
when '2.3.4.7'
127-
'2.3.4.7-4'
128-
when '2.3.6.0'
129-
'2.3.6.0-3796'
130-
when '2.4.0.0'
131-
'2.4.0.0-169'
132-
when '2.4.2.0'
133-
'2.4.2.0-258'
134-
when '2.4.3.0'
135-
'2.4.3.0-227'
136-
when '2.5.0.0'
137-
'2.5.0.0-1245'
138-
when '2.5.3.0'
139-
'2.5.3.0-37'
140-
when '2.5.5.0'
141-
'2.5.5.0-157'
142-
when '2.6.0.3'
143-
'2.6.0.3-8'
144-
when '2.6.1.0'
145-
'2.6.1.0-129'
146-
else
147-
node['hadoop']['distribution_version']
148-
end
149-
150102
default['hadoop']['hadoop_env']['hadoop_opts'] = '-Djava.net.preferIPv4Stack=true ${HADOOP_OPTS}'
151103
default['hadoop']['mapred_env']['hadoop_opts'] = '-Djava.net.preferIPv4Stack=true ${HADOOP_OPTS}'
152104

@@ -158,8 +110,9 @@
158110

159111
distro = node['hadoop']['distribution']
160112
lzo_jar = distro == 'hdp' ? 'hadoop-lzo-0.6.0.${hdp.version}.jar' : 'hadoop-lzo-0.5.1.jar'
161-
default['hadoop']['hadoop_env']['hadoop_opts'] += " -D#{distro}.version=#{full_version}"
162-
default['hadoop']['mapred_env']['hadoop_opts'] += " -D#{distro}.version=#{full_version}"
113+
# %{_FULL_VERSION} will be interpolated in the default recipe, when helper libraries are available
114+
default['hadoop']['hadoop_env']['hadoop_opts'] += " -D#{distro}.version=%<_FULL_VERSION>s"
115+
default['hadoop']['mapred_env']['hadoop_opts'] += " -D#{distro}.version=%<_FULL_VERSION>s"
163116
default['hadoop']['mapred_site']['mapreduce.admin.map.child.java.opts'] =
164117
"-server -Djava.net.preferIPv4Stack=true -D#{distro}.version=${#{distro}.version}"
165118
default['hadoop']['mapred_site']['mapreduce.admin.user.env'] =

recipes/default.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,14 @@
162162
# rubocop:enable Style/Next
163163
end
164164

165+
# Evaluate any Delayed Interpolation tokens in *-env attributes
166+
delayed_attrs = { _FULL_VERSION: hdp_version }
167+
if node['hadoop'].key?(envfile) && !node['hadoop'][envfile].empty?
168+
node['hadoop'][envfile].each do |k, v|
169+
node.default['hadoop'][envfile][k] = v % delayed_attrs
170+
end
171+
end
172+
165173
template "#{hadoop_conf_dir}/#{envfile.tr('_', '-')}.sh" do
166174
source 'generic-env.sh.erb'
167175
mode '0755'

spec/default_spec.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,18 @@
8686
)
8787
end
8888

89+
it 'renders file hadoop-env.sh with HADOOP_OPTS containing the correct hdp.version' do
90+
expect(chef_run).to render_file('/etc/hadoop/conf.chef/hadoop-env.sh').with_content(
91+
/HADOOP_OPTS.*2.3.4.7-4/
92+
)
93+
end
94+
95+
it 'renders file mapred-env.sh with HADOOP_OPTS containing the correct hdp.version' do
96+
expect(chef_run).to render_file('/etc/hadoop/conf.chef/mapred-env.sh').with_content(
97+
/HADOOP_OPTS.*2.3.4.7-4/
98+
)
99+
end
100+
89101
it 'renders file hadoop-policy.xml with test.property' do
90102
expect(chef_run).to render_file('/etc/hadoop/conf.chef/hadoop-policy.xml').with_content(
91103
/test.property/

0 commit comments

Comments
 (0)