Skip to content

Commit

Permalink
MINOR: upgrade to jdk8 8u202
Browse files Browse the repository at this point in the history
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 <jarek@confluent.io>
Author: Ewen Cheslack-Postava <me@ewencp.org>

Reviewers: Alex Diachenko <sansanichfb@gmail.com>, Ewen Cheslack-Postava <ewen@confluent.io>

Closes apache#6165 from jarekr/trunk-jdk8-from-tgz
  • Loading branch information
Jarek Rudzinski authored and ewencp committed Jan 25, 2019
1 parent 0f926f0 commit ad3b6dd
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 40 deletions.
20 changes: 7 additions & 13 deletions Vagrantfile
Expand Up @@ -40,7 +40,7 @@ ec2_keypair_file = nil

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

jdk_major = '8'
jdk_full = '8u202-linux-x64'

local_config_file = File.join(File.dirname(__FILE__), "Vagrantfile.local")
if File.exists?(local_config_file) then
eval(File.read(local_config_file), binding, "Vagrantfile.local")
Expand All @@ -75,15 +78,6 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|

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

Expand Down Expand Up @@ -169,7 +163,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
name_node(zookeeper, name, ec2_instance_name_prefix)
ip_address = "192.168.50." + (10 + i).to_s
assign_local_ip(zookeeper, ip_address)
zookeeper.vm.provision "shell", path: "vagrant/base.sh"
zookeeper.vm.provision "shell", path: "vagrant/base.sh", env: {"JDK_MAJOR" => jdk_major, "JDK_FULL" => jdk_full}
zk_jmx_port = enable_jmx ? (8000 + i).to_s : ""
zookeeper.vm.provision "shell", path: "vagrant/zk.sh", :args => [i.to_s, num_zookeepers, zk_jmx_port]
end
Expand All @@ -186,7 +180,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# host DNS isn't setup, we shouldn't use hostnames -- IP addresses must be
# used to support clients running on the host.
zookeeper_connect = zookeepers.map{ |zk_addr| zk_addr + ":2181"}.join(",")
broker.vm.provision "shell", path: "vagrant/base.sh"
broker.vm.provision "shell", path: "vagrant/base.sh", env: {"JDK_MAJOR" => jdk_major, "JDK_FULL" => jdk_full}
kafka_jmx_port = enable_jmx ? (9000 + i).to_s : ""
broker.vm.provision "shell", path: "vagrant/broker.sh", :args => [i.to_s, enable_dns ? name : ip_address, zookeeper_connect, kafka_jmx_port]
end
Expand All @@ -198,7 +192,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
name_node(worker, name, ec2_instance_name_prefix)
ip_address = "192.168.50." + (100 + i).to_s
assign_local_ip(worker, ip_address)
worker.vm.provision "shell", path: "vagrant/base.sh"
worker.vm.provision "shell", path: "vagrant/base.sh", env: {"JDK_MAJOR" => jdk_major, "JDK_FULL" => jdk_full}
end
}

Expand Down
61 changes: 34 additions & 27 deletions vagrant/base.sh
Expand Up @@ -20,38 +20,45 @@ set -ex
# If you update this, also update tests/docker/Dockerfile
export KIBOSH_VERSION=d85ac3ec44be0700efe605c16289fd901cfdaa13

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

# Try to share cache. See Vagrantfile for details
mkdir -p /var/cache/oracle-jdk8-installer
if [ -e "/tmp/oracle-jdk8-installer-cache/" ]; then
find /tmp/oracle-jdk8-installer-cache/ -not -empty -exec cp '{}' /var/cache/oracle-jdk8-installer/ \;
fi
if [ ! -e "/var/cache/oracle-jdk8-installer/jdk-8u171-linux-x64.tar.gz" ]; then
# Grab a copy of the JDK since it has moved and original downloader won't work
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
fi
fetch_jdk_tgz() {
jdk_version=$1

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

# oracle-javaX-installer runs wget with a dot progress indicator which ends up
# as one line per dot in the build logs.
# To avoid this noise we redirect all output to a file that we only show if apt-get fails.
echo "Installing JDK..."
if ! apt-get -y install oracle-java8-installer oracle-java8-set-default >/tmp/jdk_install.log 2>&1 ; then
cat /tmp/jdk_install.log
echo "ERROR: JDK install failed"
exit 1
fi
if [ ! -e $path ]; then
mkdir -p $(dirname $path)
curl -s -L "https://s3-us-west-2.amazonaws.com/kafka-packages/jdk-${jdk_version}.tar.gz" -o $path
fi
}

JDK_MAJOR="${JDK_MAJOR:-8}"
JDK_FULL="${JDK_FULL:-8u202-linux-x64}"

if [ -z `which javac` ]; then
apt-get -y update
apt-get install -y software-properties-common python-software-properties binutils java-common

echo "===> Installing JDK..."

mkdir -p /opt/jdk
cd /opt/jdk
rm -rf $JDK_MAJOR
mkdir -p $JDK_MAJOR
cd $JDK_MAJOR
fetch_jdk_tgz $JDK_FULL
tar x --strip-components=1 -zf $(path_to_jdk_cache $JDK_FULL)
for bin in /opt/jdk/$JDK_MAJOR/bin/* ; do
name=$(basename $bin)
update-alternatives --install /usr/bin/$name $name $bin 1081 && update-alternatives --set $name $bin
done
echo -e "export JAVA_HOME=/opt/jdk/$JDK_MAJOR\nexport PATH=\$PATH:\$JAVA_HOME/bin" > /etc/profile.d/jdk.sh
echo "JDK installed: $(javac -version 2>&1)"

if [ -e "/tmp/oracle-jdk8-installer-cache/" ]; then
cp -R /var/cache/oracle-jdk8-installer/* /tmp/oracle-jdk8-installer-cache
fi
fi

chmod a+rw /opt
Expand Down

0 comments on commit ad3b6dd

Please sign in to comment.