Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure Java 8 is installed #146

Merged
merged 1 commit into from
Oct 6, 2016
Merged

Ensure Java 8 is installed #146

merged 1 commit into from
Oct 6, 2016

Conversation

serialx
Copy link
Contributor

@serialx serialx commented Sep 8, 2016

Since Spark 2.0 Java 1.7 is deprecated. And many of the optimisations require Java 1.8. This patch ensures Java 1.8 in CentOS-like distros including Amazon Linux. It also removes any previous versions of Java to resolve any possible version conflicts.

This closes #143

I've tested this with our production deployment.

@serialx serialx force-pushed the java8 branch 6 times, most recently from 147b310 to 63ef844 Compare September 9, 2016 05:51

for command in possible_cmds:
try:
output = ssh_check_output(
Copy link
Owner

@nchammas nchammas Sep 9, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I think this will always return an empty string because java -version spits its output on stderr, whereas ssh_check_output() only returns stdout.

Ultimately, I want to change ssh_check_output() so that it cleanly returns both stdout and stderr, but in the meantime you can fix this by updating your possible_cmds to redirect stderr to stdout.

$ORIGINAL_COMMAND 2>&1

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, you're right. There should be no output!

But I've tested this code many times to confirm the output. Let me test this again.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will still work for the current default AMIs because no output means Java 8 gets installed, but it will do unnecessary work if Java 8 is already installed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, my main test case was Amazon Linux where Java 1.7 is installed by default. I've confirmed the function returning (1, 7).

But just in case, I'll add 2>&1 to the code.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right. No idea why that's happening... Thanks for patching that up anyway.

@serialx
Copy link
Contributor Author

serialx commented Sep 9, 2016

Updated to redirect stderr to stdout. Should work even if the behaviour of ssh_check_output() changes.

@nchammas
Copy link
Owner

Hey @serialx, sorry about the delay in finishing up the review on this. I'll hopefully get to this sometime next week.

Copy link
Owner

@nchammas nchammas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me and I tested it out. Just a couple of minor comments about wording/comments and we can merge this in.

Sorry about the delays in reviewing this @serialx!

host = client.get_transport().getpeername()[0]
java_major_version = get_java_major_version(client)

# The default CentOS AMIs on EC2 don't come with Java installed.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can remove this comment and the one immediately below it.

sudo yum install -y java-1.8.0-openjdk

# Remove any older versions of Java to force the default Java to 1.8.
# We don't use alternatives because it does not seem to update links in /usr/lib/jvm correctly,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we update this to say "We don't use /etc/alternatives..." or something like that so it's clear that we're talking about a specific piece software? Otherwise I will probably forget what this is about in a few months. 😆

@serialx
Copy link
Contributor Author

serialx commented Oct 6, 2016

Done! :)

Since Spark 2.0 Java 1.7 is deprecated. And many of the optimisations
require Java 1.8. This patch ensures Java 1.8 in CentOS-like distros
including Amazon Linux. It also removes any previous versions of Java
to resolve any possible version conflicts.

This closes nchammas#143
@nchammas
Copy link
Owner

nchammas commented Oct 6, 2016

Excellent. Thank you for your patience!

@nchammas nchammas merged commit 96588eb into nchammas:master Oct 6, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ensure Java >= 8 on launched nodes
2 participants