Skip to content

Cannot upgrade java version #649

@brailsmt

Description

@brailsmt

🗣️ Foreword

While working with the latest version of the java cookbook and chef 16, we are unable to upgrade to a later java version. We often need to uplift to a newer java version due to security and bug fixes. We are not yet running in a containerized environment so we need the ability to upgrade java versions even if previous versions were installed. We are also unable to safely remove all old installations of java prior to upgrading.

👻 Brief Description

If java has already been installed on the node in question, then subsequent runs of the sous-chef/java recipe will silently fail to upgrade the java version. We have created a thin wrapper around the java resource to install java. The recipe is essentially this (actual values changed, obviously):

adoptopenjdk_install '8' do
  variant node['some']['config']['java_variant']
  url node['some]['config']['java_url']
  checksum node['some']['config']['java_checksum']
end

If we run chef-client -o "recipe[company_java]", the chef-client run succeeds. If we then override the config and install a new version of java, it fails to upgrade the java version, but the cookbook still succeeds.

🥞 Cookbook version

We are experiencing this with 8.4.0.

👩‍🍳 Chef-Infra Version

16.6.14

🎩 Platform details

Oracle Linux 7.9

Steps To Reproduce

Steps to reproduce the behavior:

  1. Use the java resource to install a version of java, for example 'adoptopenjdk', '8', 'hotspot' with this URL: https://github.com/AdoptOpenJDK/openjdk8-upstream-binaries/releases/download/jdk8u272-b10/OpenJDK8U-jdk_x64_linux_8u272b10.tar.gz
  2. Attempt to upgrade the java version using the same variant, version, and flavor but using this URL: https://github.com/AdoptOpenJDK/openjdk8-upstream-binaries/releases/download/jdk8u275-b01/OpenJDK8U-jdk_x64_linux_8u275b01.tar.gz

/usr/lib/jvm/java-8-adoptopenjdk-hotspot will contain the jdk8u272-b10 directory, and there will not be a jdk8u275-b01 directory.

🚓 Expected behavior

The expected behavior is that version of java that was installed in step 2 would be the java version installed and linked through /etc/alternatives.

➕ Additional context

Here is a snippet from a chef-client run that was intended to install jdk8u232-b09:

  * adoptopenjdk_install[8] action install[2021-01-15T15:39:01-06:00] INFO: Processing adoptopenjdk_install[8] action install (cloudiam_java::default line 2)

    * adoptopenjdk_linux_install[8] action install[2021-01-15T15:39:01-06:00] INFO: Processing adoptopenjdk_linux_install[8] action install (/var/chef/cache/cookbooks/java/resources/adoptopenjdk_install.rb line 49)

      * directory[/usr/lib/jvm] action create[2021-01-15T15:39:01-06:00] INFO: Processing directory[/usr/lib/jvm] action create (/var/chef/cache/cookbooks/java/resources/adoptopenjdk_linux_install.rb line 57)
 (up to date)
      * remote_file[/var/chef/cache/OpenJDK8U-jdk_x64_linux_hotspot_8u232b09.tar.gz] action create[2021-01-15T15:39:01-06:00] INFO: Processing remote_file[/var/chef/cache/OpenJDK8U-jdk_x64_linux_hotspot_8u232b09.tar.gz] action create (/var/chef/cache/cookbooks/java/resources/adoptopenjdk_linux_install.rb line 64)
 (up to date)
      * archive_file[/var/chef/cache/OpenJDK8U-jdk_x64_linux_hotspot_8u232b09.tar.gz] action extract[2021-01-15T15:39:02-06:00] INFO: Processing archive_file[/var/chef/cache/OpenJDK8U-jdk_x64_linux_hotspot_8u232b09.tar.gz] action extract (/var/chef/cache/cookbooks/java/resources/adoptopenjdk_linux_install.rb line 72)
[2021-01-15T15:39:02-06:00] DEBUG: Not extracting archive as /usr/lib/jvm/java-8-adoptopenjdk-hotspot exists and resource not set to overwrite.

Instead of the application being run with jdk8u232-b09, it was running with the version of java that was previously installed which happened to be jdk8u265-b01. While the version that was previously installed was newer is beside the point and is due to a separate issue in our own cookbooks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions