sous-chefs / java

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

corretto_install extract directory problems #599

Closed sfiggins closed 3 years ago

sfiggins commented 4 years ago

:ghost: Brief Description

When testing use of version 8.0.1 of this cookbook on centos 7 I noticed that the extract_dir (/usr/lib/jvm/java-8-corretto) were 01363 or d-wxrw--wt.

Technically this is the result of a bug in archive_file, but it causes problems for the java cookbook and reveals another problem related to a shared extract_dir: You can't effectively update your source or provide two java versions of the the same flavor. (i.e. You can't have two different java-8-corretto versions. )

:pancakes: Cookbook version

8.0.1

:woman_cook: Chef-Infra Version

15.8.23

:tophat: Platform details

kitchen run against corretto-8-centos-7, using centos 7 bento. My testing system is OS X Catalina. I'm using vagrant and virtual box.

Steps To Reproduce

With checkout of java cookbook from master run

kitchen converge corretto-8-centos-7

:police_car: Expected behavior

The extract directory permissions for usr/lib/jvm/java-8-corretto should be '0755'

:heavy_plus_sign: Additional context

This is actually an archive_file problem with Chef 15.

https://github.com/chef/chef/blob/f2aacc890c732ca481dbbe890d9a035b37c4dafb/lib/chef/resource/archive_file.rb

  FileUtils.mkdir_p(new_resource.destination, mode: new_resource.mode.to_i)

This wants an octal input, but it gets an integer, 755 decimal -> 01363 octal.

I tried routing around the problem by creating the extract_dir before the corretto_install

When extract_dir exists though, archive_file did not extract the archive. This reveals another problem with the archive_dir approach here.

Limit one flavor of the same java version per customer

Currently if wanted to install two different corretto 8 versions the second would fail to extract, since the name of the extract directory is determined by your java version. This is pretty common need for me with jenkins, for example.

I have not tested this implementation yet against other distributions, or other jdk's, but the resource code is the same, so I expect the problem will exist for them as well.

Possible workaround: set overwrite true on the archive_file resource? I think that's leads to some confusing log output from archive_file, but as written the extract_dir cannot exist. if I update my path to extract to /usr/lib/jvm/amazon-corretto-11.0.6.10.1-linux-x64 deploy would fail because /usr/lib/jvm exists.

damacus commented 4 years ago

Thanks for this. Looks like there isn't a fix until Chef 16. Unless it gets backported, I might suggest we revert the addition of archive.

github-actions[bot] commented 3 years ago

Marking stale due to inactivity. Remove stale label or comment or this will be closed in 7 days. Alternatively drop by the #sous-chefs channel on the Chef Community Slack and we'll be happy to help! Thanks, Sous-Chefs.

github-actions[bot] commented 3 years ago

Closing due to inactivity. If this is still an issue please reopen or open another issue. Alternatively drop by the #sous-chefs channel on the Chef Community Slack and we'll be happy to help! Thanks, Sous-Chefs.