Skip to content

Commit ad3b6dd

Browse files
Jarek Rudzinskiewencp
Jarek Rudzinski
authored andcommitted
MINOR: upgrade to jdk8 8u202
Upgrade from 171 to 202. Unpack and install directly from a cached tgz rather than going via the installer deb from webupd8. The installer is still on 8u919 while we want 202. Testing via kafka branch builder job https://jenkins.confluent.io/job/system-test-kafka-branch-builder/2305/ Author: Jarek Rudzinski <[email protected]> Author: Ewen Cheslack-Postava <[email protected]> Reviewers: Alex Diachenko <[email protected]>, Ewen Cheslack-Postava <[email protected]> Closes apache#6165 from jarekr/trunk-jdk8-from-tgz
1 parent 0f926f0 commit ad3b6dd

File tree

2 files changed

+41
-40
lines changed

2 files changed

+41
-40
lines changed

Vagrantfile

+7-13
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ ec2_keypair_file = nil
4040

4141
ec2_region = "us-east-1"
4242
ec2_az = nil # Uses set by AWS
43-
ec2_ami = "ami-905730e8"
43+
ec2_ami = "ami-29ebb519"
4444
ec2_instance_type = "m3.medium"
4545
ec2_spot_instance = ENV['SPOT_INSTANCE'] ? ENV['SPOT_INSTANCE'] == 'true' : true
4646
ec2_spot_max_price = "0.113" # On-demand price for instance type
@@ -52,6 +52,9 @@ ec2_subnet_id = nil
5252
# are running Vagrant from within that VPC as well.
5353
ec2_associate_public_ip = nil
5454

55+
jdk_major = '8'
56+
jdk_full = '8u202-linux-x64'
57+
5558
local_config_file = File.join(File.dirname(__FILE__), "Vagrantfile.local")
5659
if File.exists?(local_config_file) then
5760
eval(File.read(local_config_file), binding, "Vagrantfile.local")
@@ -75,15 +78,6 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
7578

7679
if Vagrant.has_plugin?("vagrant-cachier")
7780
override.cache.scope = :box
78-
# Besides the defaults, we use a custom cache to handle the Oracle JDK
79-
# download, which downloads via wget during an apt install. Because of the
80-
# way the installer ends up using its cache directory, we need to jump
81-
# through some hoops instead of just specifying a cache directly -- we
82-
# share to a temporary location and the provisioning scripts symlink data
83-
# to the right location.
84-
override.cache.enable :generic, {
85-
"oracle-jdk8" => { cache_dir: "/tmp/oracle-jdk8-installer-cache" },
86-
}
8781
end
8882
end
8983

@@ -169,7 +163,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
169163
name_node(zookeeper, name, ec2_instance_name_prefix)
170164
ip_address = "192.168.50." + (10 + i).to_s
171165
assign_local_ip(zookeeper, ip_address)
172-
zookeeper.vm.provision "shell", path: "vagrant/base.sh"
166+
zookeeper.vm.provision "shell", path: "vagrant/base.sh", env: {"JDK_MAJOR" => jdk_major, "JDK_FULL" => jdk_full}
173167
zk_jmx_port = enable_jmx ? (8000 + i).to_s : ""
174168
zookeeper.vm.provision "shell", path: "vagrant/zk.sh", :args => [i.to_s, num_zookeepers, zk_jmx_port]
175169
end
@@ -186,7 +180,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
186180
# host DNS isn't setup, we shouldn't use hostnames -- IP addresses must be
187181
# used to support clients running on the host.
188182
zookeeper_connect = zookeepers.map{ |zk_addr| zk_addr + ":2181"}.join(",")
189-
broker.vm.provision "shell", path: "vagrant/base.sh"
183+
broker.vm.provision "shell", path: "vagrant/base.sh", env: {"JDK_MAJOR" => jdk_major, "JDK_FULL" => jdk_full}
190184
kafka_jmx_port = enable_jmx ? (9000 + i).to_s : ""
191185
broker.vm.provision "shell", path: "vagrant/broker.sh", :args => [i.to_s, enable_dns ? name : ip_address, zookeeper_connect, kafka_jmx_port]
192186
end
@@ -198,7 +192,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
198192
name_node(worker, name, ec2_instance_name_prefix)
199193
ip_address = "192.168.50." + (100 + i).to_s
200194
assign_local_ip(worker, ip_address)
201-
worker.vm.provision "shell", path: "vagrant/base.sh"
195+
worker.vm.provision "shell", path: "vagrant/base.sh", env: {"JDK_MAJOR" => jdk_major, "JDK_FULL" => jdk_full}
202196
end
203197
}
204198

vagrant/base.sh

+34-27
Original file line numberDiff line numberDiff line change
@@ -20,38 +20,45 @@ set -ex
2020
# If you update this, also update tests/docker/Dockerfile
2121
export KIBOSH_VERSION=d85ac3ec44be0700efe605c16289fd901cfdaa13
2222

23-
if [ -z `which javac` ]; then
24-
apt-get -y update
25-
apt-get install -y software-properties-common python-software-properties
26-
add-apt-repository -y ppa:webupd8team/java
27-
apt-get -y update
23+
path_to_jdk_cache() {
24+
jdk_version=$1
25+
echo "/tmp/jdk-${jdk_version}.tar.gz"
26+
}
2827

29-
# Try to share cache. See Vagrantfile for details
30-
mkdir -p /var/cache/oracle-jdk8-installer
31-
if [ -e "/tmp/oracle-jdk8-installer-cache/" ]; then
32-
find /tmp/oracle-jdk8-installer-cache/ -not -empty -exec cp '{}' /var/cache/oracle-jdk8-installer/ \;
33-
fi
34-
if [ ! -e "/var/cache/oracle-jdk8-installer/jdk-8u171-linux-x64.tar.gz" ]; then
35-
# Grab a copy of the JDK since it has moved and original downloader won't work
36-
curl -s -L "https://s3-us-west-2.amazonaws.com/kafka-packages/jdk-8u171-linux-x64.tar.gz" -o /var/cache/oracle-jdk8-installer/jdk-8u171-linux-x64.tar.gz
37-
fi
28+
fetch_jdk_tgz() {
29+
jdk_version=$1
3830

39-
/bin/echo debconf shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections
31+
path=$(path_to_jdk_cache $jdk_version)
4032

41-
# oracle-javaX-installer runs wget with a dot progress indicator which ends up
42-
# as one line per dot in the build logs.
43-
# To avoid this noise we redirect all output to a file that we only show if apt-get fails.
44-
echo "Installing JDK..."
45-
if ! apt-get -y install oracle-java8-installer oracle-java8-set-default >/tmp/jdk_install.log 2>&1 ; then
46-
cat /tmp/jdk_install.log
47-
echo "ERROR: JDK install failed"
48-
exit 1
49-
fi
33+
if [ ! -e $path ]; then
34+
mkdir -p $(dirname $path)
35+
curl -s -L "https://s3-us-west-2.amazonaws.com/kafka-packages/jdk-${jdk_version}.tar.gz" -o $path
36+
fi
37+
}
38+
39+
JDK_MAJOR="${JDK_MAJOR:-8}"
40+
JDK_FULL="${JDK_FULL:-8u202-linux-x64}"
41+
42+
if [ -z `which javac` ]; then
43+
apt-get -y update
44+
apt-get install -y software-properties-common python-software-properties binutils java-common
45+
46+
echo "===> Installing JDK..."
47+
48+
mkdir -p /opt/jdk
49+
cd /opt/jdk
50+
rm -rf $JDK_MAJOR
51+
mkdir -p $JDK_MAJOR
52+
cd $JDK_MAJOR
53+
fetch_jdk_tgz $JDK_FULL
54+
tar x --strip-components=1 -zf $(path_to_jdk_cache $JDK_FULL)
55+
for bin in /opt/jdk/$JDK_MAJOR/bin/* ; do
56+
name=$(basename $bin)
57+
update-alternatives --install /usr/bin/$name $name $bin 1081 && update-alternatives --set $name $bin
58+
done
59+
echo -e "export JAVA_HOME=/opt/jdk/$JDK_MAJOR\nexport PATH=\$PATH:\$JAVA_HOME/bin" > /etc/profile.d/jdk.sh
5060
echo "JDK installed: $(javac -version 2>&1)"
5161

52-
if [ -e "/tmp/oracle-jdk8-installer-cache/" ]; then
53-
cp -R /var/cache/oracle-jdk8-installer/* /tmp/oracle-jdk8-installer-cache
54-
fi
5562
fi
5663

5764
chmod a+rw /opt

0 commit comments

Comments
 (0)