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

"Alternatives" not being set on Amazon AMI #120

Closed
awesometown opened this issue Jan 16, 2014 · 10 comments
Closed

"Alternatives" not being set on Amazon AMI #120

awesometown opened this issue Jan 16, 2014 · 10 comments

Comments

@awesometown
Copy link

I'm trying to launch an Amazon Linux instance in OpsWorks and have it get upgraded to Java 7. It appears that it's getting installed fine, but the call to set it as the default version using alternatives isn't taking. When I log into the instance and run "java -version" I still get:

java version "1.6.0_24"
OpenJDK Runtime Environment (IcedTea6 1.11.14) (amazon-65.1.11.14.57.amzn1-x86_64)
OpenJDK 64-Bit Server VM (build 20.0-b12, mixed mode)

If I run sudo alternatives --config java I see

*+ 1           /usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/java
   2           /usr/lib/jvm/jre-1.7.0-openjdk.x86_64/bin/java

Selecting 2 makes the change as expected.

I believe I've included the relevant bits of the log below, and there are no obvious errors. If I switch the instance type in OpsWorks to be Ubuntu, everything works fine (but then some other recipes that are more finicky break).

The only custom json I'm passing in is to specify java 7:

{
    "java": {
        "jdk_version":7
    }
}

Sorry if I've missed something obvious; I'm pretty new to all of this, but as far as I can tell, this should just work?

[2014-01-16T02:11:49+00:00] INFO: Processing package[java-1.7.0-openjdk] action install (java::openjdk line 35)
[2014-01-16T02:11:49+00:00] DEBUG: package[java-1.7.0-openjdk] checking yum info for java-1.7.0-openjdk
[2014-01-16T02:11:49+00:00] DEBUG: package[java-1.7.0-openjdk] installed version: (none) candidate version: 1.7.0.45-2.4.3.2.32.amzn1
[2014-01-16T02:11:49+00:00] INFO: package[java-1.7.0-openjdk] installing java-1.7.0-openjdk-1.7.0.45-2.4.3.2.32.amzn1 from amzn-updates repository
[2014-01-16T02:11:49+00:00] DEBUG: Executing yum -d0 -e0 -y install java-1.7.0-openjdk-1.7.0.45-2.4.3.2.32.amzn1
[2014-01-16T02:11:58+00:00] DEBUG: ---- Begin output of yum -d0 -e0 -y install java-1.7.0-openjdk-1.7.0.45-2.4.3.2.32.amzn1 ----
[2014-01-16T02:11:58+00:00] DEBUG: STDOUT: 
[2014-01-16T02:11:58+00:00] DEBUG: STDERR: 
[2014-01-16T02:11:58+00:00] DEBUG: ---- End output of yum -d0 -e0 -y install java-1.7.0-openjdk-1.7.0.45-2.4.3.2.32.amzn1 ----
[2014-01-16T02:11:58+00:00] DEBUG: Ran yum -d0 -e0 -y install java-1.7.0-openjdk-1.7.0.45-2.4.3.2.32.amzn1 returned 0
[2014-01-16T02:11:58+00:00] INFO: Processing package[java-1.7.0-openjdk-devel] action install (java::openjdk line 35)
[2014-01-16T02:12:00+00:00] DEBUG: package[java-1.7.0-openjdk-devel] checking yum info for java-1.7.0-openjdk-devel
[2014-01-16T02:12:00+00:00] DEBUG: package[java-1.7.0-openjdk-devel] installed version: (none) candidate version: 1.7.0.45-2.4.3.2.32.amzn1
[2014-01-16T02:12:00+00:00] INFO: package[java-1.7.0-openjdk-devel] installing java-1.7.0-openjdk-devel-1.7.0.45-2.4.3.2.32.amzn1 from amzn-updates repository
[2014-01-16T02:12:00+00:00] DEBUG: Executing yum -d0 -e0 -y install java-1.7.0-openjdk-devel-1.7.0.45-2.4.3.2.32.amzn1
[2014-01-16T02:12:04+00:00] DEBUG: ---- Begin output of yum -d0 -e0 -y install java-1.7.0-openjdk-devel-1.7.0.45-2.4.3.2.32.amzn1 ----
[2014-01-16T02:12:04+00:00] DEBUG: STDOUT: 
[2014-01-16T02:12:04+00:00] DEBUG: STDERR: 
[2014-01-16T02:12:04+00:00] DEBUG: ---- End output of yum -d0 -e0 -y install java-1.7.0-openjdk-devel-1.7.0.45-2.4.3.2.32.amzn1 ----
[2014-01-16T02:12:04+00:00] DEBUG: Ran yum -d0 -e0 -y install java-1.7.0-openjdk-devel-1.7.0.45-2.4.3.2.32.amzn1 returned 0
[2014-01-16T02:12:04+00:00] INFO: Processing java_alternatives[set-java-alternatives] action set (java::openjdk line 39)
[2014-01-16T02:12:04+00:00] INFO: Processing ruby_block[set-env-java-home] action run (java::set_java_home line 19)
[2014-01-16T02:12:04+00:00] INFO: ruby_block[set-env-java-home] called
[2014-01-16T02:12:04+00:00] INFO: Processing directory[/etc/profile.d] action create (java::set_java_home line 26)
[2014-01-16T02:12:04+00:00] INFO: Processing file[/etc/profile.d/jdk.sh] action create (java::set_java_home line 30)
[2014-01-16T02:12:05+00:00] INFO: entered create
[2014-01-16T02:12:05+00:00] INFO: file[/etc/profile.d/jdk.sh] mode changed to 755
[2014-01-16T02:12:05+00:00] INFO: file[/etc/profile.d/jdk.sh] created file /etc/profile.d/jdk.sh
[2014-01-16T02:12:05+00:00] INFO: Processing package[sun-java6-jdk] action purge (java::default line 56)
[2014-01-16T02:12:05+00:00] DEBUG: Skipping package[sun-java6-jdk] due to only_if ruby block
[2014-01-16T02:12:05+00:00] INFO: Processing package[sun-java6-bin] action purge (java::default line 56)
[2014-01-16T02:12:05+00:00] DEBUG: Skipping package[sun-java6-bin] due to only_if ruby block
[2014-01-16T02:12:05+00:00] INFO: Processing package[sun-java6-jre] action purge (java::default line 56)
[2014-01-16T02:12:05+00:00] DEBUG: Skipping package[sun-java6-jre] due to only_if ruby block
@awesometown
Copy link
Author

Looks like all of the other java tools are being pointed at Java 7 properly, but java is not. This is part of an ls of /etc/alternatives:

lrwxrwxrwx  1 root root   46 Jan 16 02:44 jar -> /usr/lib/jvm/java-1.7.0-openjdk.x86_64/bin/jar
lrwxrwxrwx  1 root root   47 Jan 16 02:44 jar.1.gz -> /usr/share/man/man1/jar-java-1.7.0-openjdk.1.gz
lrwxrwxrwx  1 root root   52 Jan 16 02:44 jarsigner -> /usr/lib/jvm/java-1.7.0-openjdk.x86_64/bin/jarsigner
lrwxrwxrwx  1 root root   53 Jan 16 02:44 jarsigner.1.gz -> /usr/share/man/man1/jarsigner-java-1.7.0-openjdk.1.gz
lrwxrwxrwx  1 root root   46 Jan 16 02:44 java -> /usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/java
lrwxrwxrwx  1 root root   48 Jan 16 02:44 java.1.gz -> /usr/share/man/man1/java-java-1.6.0-openjdk.1.gz
lrwxrwxrwx  1 root root   48 Jan 16 02:44 javac -> /usr/lib/jvm/java-1.7.0-openjdk.x86_64/bin/javac
lrwxrwxrwx  1 root root   49 Jan 16 02:44 javac.1.gz -> /usr/share/man/man1/javac-java-1.7.0-openjdk.1.gz
lrwxrwxrwx  1 root root   50 Jan 16 02:44 javadoc -> /usr/lib/jvm/java-1.7.0-openjdk.x86_64/bin/javadoc
lrwxrwxrwx  1 root root   51 Jan 16 02:44 javadoc.1.gz -> /usr/share/man/man1/javadoc-java-1.7.0-openjdk.1.gz
lrwxrwxrwx  1 root root   48 Jan 16 02:44 javah -> /usr/lib/jvm/java-1.7.0-openjdk.x86_64/bin/javah
lrwxrwxrwx  1 root root   49 Jan 16 02:44 javah.1.gz -> /usr/share/man/man1/javah-java-1.7.0-openjdk.1.gz
lrwxrwxrwx  1 root root   48 Jan 16 02:44 javap -> /usr/lib/jvm/java-1.7.0-openjdk.x86_64/bin/javap
lrwxrwxrwx  1 root root   49 Jan 16 02:44 javap.1.gz -> /usr/share/man/man1/javap-java-1.7.0-openjdk.1.gz
lrwxrwxrwx  1 root root   38 Jan 16 02:44 java_sdk -> /usr/lib/jvm/java-1.7.0-openjdk.x86_64
lrwxrwxrwx  1 root root   38 Jan 16 02:44 java_sdk_1.7.0 -> /usr/lib/jvm/java-1.7.0-openjdk.x86_64
lrwxrwxrwx  1 root root   46 Jan 16 02:44 java_sdk_1.7.0_exports -> /usr/lib/jvm-exports/java-1.7.0-openjdk.x86_64
lrwxrwxrwx  1 root root   46 Jan 16 02:44 java_sdk_exports -> /usr/lib/jvm-exports/java-1.7.0-openjdk.x86_64
lrwxrwxrwx  1 root root   38 Jan 16 02:44 java_sdk_openjdk -> /usr/lib/jvm/java-1.7.0-openjdk.x86_64
lrwxrwxrwx  1 root root   46 Jan 16 02:44 java_sdk_openjdk_exports -> /usr/lib/jvm-exports/java-1.7.0-openjdk.x86_64

@carmstrong
Copy link
Contributor

@awesometown, out of curiosity, can you try using the latest from master? I'm wondering if #119 may have fixed it. We really need to figure out a better way to have test coverage for upgrades...

@carmstrong
Copy link
Contributor

I was able to replicate this (at least installing openjdk-7 fresh). It looks like the home directory isn't being set properly for RHEL families. @awesometown, could you try the latest from master? Specifically: 71dadbd

@awesometown
Copy link
Author

Doesn't look like it.

$JAVA_HOME is set to /usr/lib/jvm/java-1.7.0 (looks like it was /usr/lib/jvm/java before) but the alternatives behavior is the same.

@carmstrong
Copy link
Contributor

Yeah, that was my fix - /usr/lib/jvm/java didn't seem to exist on fresh openjdk installs.

Can you figure out what the alternative priority for java is currently? Your output shows that openjdk 6 is definitely a higher priority than 7, but knowing what the actual alternative priority is will help debug. Some logic probably needs to be fixed in alternatives_priority: https://github.com/socrata-cookbooks/java/blob/master/libraries/helpers.rb#L37

@awesometown
Copy link
Author

We're pushing the bounds of my linux knowledge here, but if I do alternatives --display java I get:

 link currently points to /usr/lib/jvm/jre-1.7.0-openjdk.x86_64/bin/java
/usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/java - priority 16000
...
/usr/lib/jvm/jre-1.7.0-openjdk.x86_64/bin/java - priority 1700
...
Current `best' version is /usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/java.

Which I guess is saying that Java 6 has a priority of 16000 while Java 7 only has 1700?

@carmstrong
Copy link
Contributor

Yep, that explains it. How it ever got into that state, I'm not sure - the cookbook only sets things at around 1600 or 1700. Amazon Linux must use different priority defaults.

I suppose the alternatives logic should be rewritten to set the alternatives at the next-highest priority so that they take effect for sure.

@carmstrong
Copy link
Contributor

So, I'm not convinced priority is an issue here at all. It looks like the alternatives code uses --set to explicitly set the current alternative. I'm wondering why https://github.com/socrata-cookbooks/java/blob/master/providers/alternatives.rb#L55 never fires in your execution...

@carmstrong
Copy link
Contributor

This should be fixed in v1.19.2

@lock
Copy link

lock bot commented May 3, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators May 3, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants