sous-chefs / java

Development repository for the java cookbook
https://supermarket.chef.io/cookbooks/java
Apache License 2.0
387 stars 636 forks source link

Java 11 install #484

Closed ronabop closed 6 years ago

ronabop commented 6 years ago

The code for Java >=10: https://github.com/sous-chefs/java/blob/master/resources/oracle_install.rb#L211-L218

Introduced with: https://github.com/sous-chefs/java/commit/c77ffd8dc5e8820a95b91ec4a555be4c2afc106f

...Does not work with Java 11, as the tarball is now in the format of jdk-11_linux-x64_bin.tar.gz.

The semantic versioning (and action to move the tarball) that expects three digits breaks on this kind of file name.

When the source tarball is renamed (to download from a local artifactory) from jdk-11_linux-x64_bin.tar.gz to jdk-11.0.0_linux-x64_bin.tar.gz, parse_app_dir_name will succeed, but the actual extracted tarball creates a folder of jdk-11, so the mv command (from cache folder to target folder) fails.

(In addition, the bin_cmds for the jdk 11 family probably need to be added).

More details:

Cookbook version

2.2.0

Chef-client version

14.3.37

Platform Details

Oracle Linux 7.5

Scenario:

Trying to install Java 11.

Steps to Reproduce:

To reproduce, create a wrapper cookbook for the java cookbook, I did it with with default attributes for java 11:

default['java']['jdk']['11']['bin_cmds'] = %w(appletviewer jar javac javapackager jconsole jdeprscan jimage jlink jmod
                                              jshell jstatd orbd rmid serialver unpack200 xjc idlj jarsigner javadoc javaws
                                              jcontrol jdeps jinfo jmap jps jstack jweblauncher pack200 rmiregistry servertool wsgen
                                              jaotc java javap jcmd jdb jhsdb jjs jmc jrunscript jstat keytool rmic schemagen tnameserv
                                              wsimport)

and node over-rides to download a specific version:

node.override['java']['install_flavor']                 = 'oracle'
node.override['java']['jdk_version']                    = '11'
node.override['java']['jdk']['11']['x86_64']['checksum'] = '246a0eba4927bf30180c573b73d55fc10e226c05b3236528c3a721dff3b50d32'
# Default name
node.override['java']['jdk']['11']['x86_64']['url']      = "https://artifactory.internal/artifactory/generic-local/java/jdk-11_linux-x64_bin.tar.gz"
# Cookbook will also fail when artifact is locally renamed
#node.override['java']['jdk']['11']['x86_64']['url']      = "https://artifactory.internal/artifactory/generic-local/java/jdk-11.0.0_linux-x64_bin.tar.gz"

Expected Result:

Install of java

Actual Result:

Install failure.

With default/expected name:

  * log[jdk-version-changed] action nothing (skipped due to action :nothing)
Recipe: java::set_java_home
  * directory[/etc/profile.d] action create (up to date)
  * template[/etc/profile.d/jdk.sh] action create (up to date)
Recipe: java::oracle
  * java_oracle_install[jdk] action install

    ================================================================================
    Error executing action `install` on resource 'java_oracle_install[jdk]'
    ================================================================================

    NoMethodError
    -------------
    undefined method `[]' for nil:NilClass

    Cookbook Trace:
    ---------------
    /var/chef/cache/cookbooks/java/resources/oracle_install.rb:214:in `parse_app_dir_name'
    /var/chef/cache/cookbooks/java/resources/oracle_install.rb:44:in `block in class_from_file'

    Resource Declaration:
    ---------------------
    # In /var/chef/cache/cookbooks/java/recipes/oracle.rb

     40: java_oracle_install 'jdk' do
     41:   url tarball_url
     42:   default node['java']['set_default']
     43:   checksum tarball_checksum
     44:   app_home java_home
     45:   bin_cmds bin_cmds
     46:   alternatives_priority node['java']['alternatives_priority']
     47:   retries node['java']['ark_retries']
     48:   retry_delay node['java']['ark_retry_delay']
     49:   connect_timeout node['java']['ark_timeout']
     50:   use_alt_suffix node['java']['use_alt_suffix']
     51:   reset_alternatives node['java']['reset_alternatives']
     52:   download_timeout node['java']['ark_download_timeout']
     53:   proxy node['java']['ark_proxy']
     54:   action :install
     55:   notifies :write, 'log[jdk-version-changed]', :immediately
     56: end
     57: 
     58: if node['java']['set_default'] && platform_family?('debian')
     59:   include_recipe 'java::default_java_symlink'
     60: end
     61: 

    Compiled Resource:
    ------------------
    # Declared in /var/chef/cache/cookbooks/java/recipes/oracle.rb:40:in `from_file'

    java_oracle_install("jdk") do
      action [:install]
      default_guard_interpreter :default
      declared_type :java_oracle_install
      cookbook_name "java"
      recipe_name "oracle"
      url "https://artifactory-internal/artifactory/generic-local/java/jdk-11_linux-x64_bin.tar.gz"
      default true
      checksum "246a0eba4927bf30180c573b73d55fc10e226c05b3236528c3a721dff3b50d32"
      app_home "/usr/lib/jvm/java"
      bin_cmds ["appletviewer", "jar", "javac", "javapackager", "jconsole", "jdeprscan", "jimage", "jlink", "jmod", "jshell", "jstatd", "orbd", "rmid", "serialver", "unpack200", "xjc", "idlj", "jarsigner", "javadoc", "javaws", "jcontrol", "jdeps", "jinfo", "jmap", "jps", "jstack", "jweblauncher", "pack200", "rmiregistry", "servertool", "wsgen", "jaotc", "java", "javap", "jcmd", "jdb", "jhsdb", "jjs", "jmc", "jrunscript", "jstat", "keytool", "rmic", "schemagen", "tnameserv", "wsimport"]
      alternatives_priority 1062
      retries 0
      retry_delay 2
      connect_timeout 600
      use_alt_suffix true
      reset_alternatives true
      download_timeout 600
      proxy nil
    end

    System Info:
    ------------
    chef_version=14.3.37
    platform=oracle
    platform_version=7.5
    ruby=ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux]
    program_name=/bin/chef-client
    executable=/opt/chef/bin/chef-client

With artifact renamed (not pulled from Oracle website), chef-client will download, but will not move the file:

  * java_oracle_install[jdk] action install
    * directory[/usr/lib/jvm] action create (up to date)
    * remote_file[/var/chef/cache/jdk-11.0.0_linux-x64_bin.tar.gz] action create_if_missing
      - create new file /var/chef/cache/jdk-11.0.0_linux-x64_bin.tar.gz
      - update content in file /var/chef/cache/jdk-11.0.0_linux-x64_bin.tar.gz from none to 246a0e
      (file sizes exceed 10000000 bytes, diff output suppressed)
      - change mode from '' to '0755'
      - restore selinux security context
    * yum_package[tar] action install (up to date)
  Recipe: base_server::oracle
    * file[/tmp/all.deploy] action delete (skipped due to only_if)

  Running handlers:
    - Chef::Handler::ErrorReport
  Running handlers complete
  Chef Client failed. 5 resources updated in 30 seconds

Relevant error lines:

[2018-09-26T16:44:52+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[2018-09-26T16:44:52+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2018-09-26T16:47:14+00:00] FATAL: Saving node information to /var/chef/cache/failed-run-data.json
[2018-09-26T16:47:43+00:00] FATAL:  Command ' mv "/var/chef/cache/jdk-11.0.0" "/usr/lib/jvm/jdk-11.0.0" ' failed 

(the cookbook expects the extracted folder to match the major.minor.patch version, the actual folder is /var/chef/cache/jdk-11 )

tas50 commented 6 years ago

2.2.1 fixes this. Thanks @ronabop

lock[bot] commented 5 years ago

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.