sous-chefs / java

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

openjdk_pkg_install reset_alternatives all the times #677

Open andrealai75 opened 1 year ago

andrealai75 commented 1 year ago

:speaking_head: Foreword

Thank for taking the time to fill this bug report fully. Without it we may not be able to fix the bug, and the issue may be closed without resolution.

:ghost: Brief Description

The openjdk_pkg_install is resetting the alternatives all the times so a new install wipes out any previous installed Java alternatives.

The issue is that the custom resource openjdk_pkg_install is calling java_alternatives setting the reset_alternatives property from new_resource.reset_alternatives but this is not defined in the resource itself so always default to true.

The fix is very simple add the following to openjdk_pkg_install:

property :reset_alternatives, [true, false], default: true, description: 'Whether to reset alternatives before setting them'

I checked openjdk_source_install and we have similar problem there

:pancakes: Cookbook version

11.1.0

:woman_cook: Chef-Infra Version

Any.

:tophat: Platform details

Any

Steps To Reproduce

Create a recipe with two openjdk_pkg_install and only the last alternative is created.

:police_car: Expected behavior

We should have one alternative for each Java installed

:heavy_plus_sign: Additional context

None

damacus commented 1 year ago

Would you like to add the simple PR to fix this? We'll happily release it

ramereth commented 4 months ago

@andrealai75 it looks this was likely fixed in a recent version. Can you please verify that's the case?