[ 
https://issues.apache.org/jira/browse/KNOX-3246?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Sandor Molnar updated KNOX-3246:
--------------------------------
    Description: 
h3. *Problem*

Knox Java discovery is non-deterministic on hosts with multiple JDK 
installations.

In environments where both Java 11 and Java 17 are installed, neither version 
is matched by the current {{{}JAVA_VERSION_PATTERNS{}}}. As a result, Java 
detection falls back to the generic {{/bin/java$}} pattern and selects the 
first match returned by {{{}find{}}}.

Because the order of results from {{find}} is not guaranteed, different hosts 
in the same cluster may select different Java versions, leading to inconsistent 
and unpredictable behavior.
----
h3. *Root Cause*
 * {{JAVA_VERSION_PATTERNS}} does not include patterns for Java 11 or Java 17 
installations.

 * {{{}/usr/java/default/bin/java{}}}, commonly used to define the 
system-preferred Java, is not recognized.

 * {{find}} is executed without {{{}-L{}}}, so symlinks are not followed.

 * The fallback selection uses {{head -n 1}} without stabilizing the result 
order.

----
h3. *Example*

On different hosts in the same cluster:
{code:java}
/usr/lib/jvm/jdk1.17.0.11.0-openjdk/bin/java
/usr/java/jdk1.11.70.15-z.0_lu/bin/java{code}
 
or
{code:java}
/usr/java/jdk1.11.70.15-z.0_lu/bin/java
/usr/lib/jvm/jdk1.17.0.11.0-openjdk/bin/java{code}
 
Depending on the host, Knox may start with Java 11 or Java 17.
----
h3. *Proposed Fix*
 * Extend {{JAVA_VERSION_PATTERNS}} to explicitly recognize Java 11 and Java 17 
layouts.

 * Add support for {{/usr/java/default/bin/java}} to honor the system default 
Java.

 * Use {{find -L}} to follow symlinks.

 * Sort Java candidates before selecting the first match to ensure 
deterministic behavior.

----
h3. *Impact*

Ensures consistent Java version selection across all nodes in a cluster, 
prevents unpredictable startup behavior, and aligns Knox Java discovery with 
common enterprise JDK layouts.

  was:
h3. *Problem*

Knox Java discovery is non-deterministic on hosts with multiple JDK 
installations.

In environments where both Java 11 and Java 17 are installed, neither version 
is matched by the current {{{}JAVA_VERSION_PATTERNS{}}}. As a result, Java 
detection falls back to the generic {{/bin/java$}} pattern and selects the 
first match returned by {{{}find{}}}.

Because the order of results from {{find}} is not guaranteed, different hosts 
in the same cluster may select different Java versions, leading to inconsistent 
and unpredictable behavior.
----
h3. *Root Cause*
 * {{JAVA_VERSION_PATTERNS}} does not include patterns for Java 11 or Java 17 
installations.

 * {{{}/usr/java/default/bin/java{}}}, commonly used to define the 
system-preferred Java, is not recognized.

 * {{find}} is executed without {{{}-L{}}}, so symlinks are not followed.

 * The fallback selection uses {{head -n 1}} without stabilizing the result 
order.

----
h3. *Example*

On different hosts in the same cluster:
/usr/lib/jvm/jdk1.17.0.11.0-openjdk/bin/java
/usr/java/jdk1.11.70.15-z.0_lu/bin/java
 
or
/usr/java/jdk1.11.70.15-z.0_lu/bin/java
/usr/lib/jvm/jdk1.17.0.11.0-openjdk/bin/java
 
Depending on the host, Knox may start with Java 11 or Java 17.
----
h3. *Proposed Fix*
 * Extend {{JAVA_VERSION_PATTERNS}} to explicitly recognize Java 11 and Java 17 
layouts.

 * Add support for {{/usr/java/default/bin/java}} to honor the system default 
Java.

 * Use {{find -L}} to follow symlinks.

 * Sort Java candidates before selecting the first match to ensure 
deterministic behavior.

----
h3. *Impact*

Ensures consistent Java version selection across all nodes in a cluster, 
prevents unpredictable startup behavior, and aligns Knox Java discovery with 
common enterprise JDK layouts.


> Make Java discovery deterministic on hosts with multiple JDKs
> -------------------------------------------------------------
>
>                 Key: KNOX-3246
>                 URL: https://issues.apache.org/jira/browse/KNOX-3246
>             Project: Apache Knox
>          Issue Type: Improvement
>          Components: Startup Scripts
>    Affects Versions: 2.1.0, 3.0.0
>            Reporter: Sandor Molnar
>            Assignee: Sandor Molnar
>            Priority: Critical
>             Fix For: 3.0.0
>
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> h3. *Problem*
> Knox Java discovery is non-deterministic on hosts with multiple JDK 
> installations.
> In environments where both Java 11 and Java 17 are installed, neither version 
> is matched by the current {{{}JAVA_VERSION_PATTERNS{}}}. As a result, Java 
> detection falls back to the generic {{/bin/java$}} pattern and selects the 
> first match returned by {{{}find{}}}.
> Because the order of results from {{find}} is not guaranteed, different hosts 
> in the same cluster may select different Java versions, leading to 
> inconsistent and unpredictable behavior.
> ----
> h3. *Root Cause*
>  * {{JAVA_VERSION_PATTERNS}} does not include patterns for Java 11 or Java 17 
> installations.
>  * {{{}/usr/java/default/bin/java{}}}, commonly used to define the 
> system-preferred Java, is not recognized.
>  * {{find}} is executed without {{{}-L{}}}, so symlinks are not followed.
>  * The fallback selection uses {{head -n 1}} without stabilizing the result 
> order.
> ----
> h3. *Example*
> On different hosts in the same cluster:
> {code:java}
> /usr/lib/jvm/jdk1.17.0.11.0-openjdk/bin/java
> /usr/java/jdk1.11.70.15-z.0_lu/bin/java{code}
>  
> or
> {code:java}
> /usr/java/jdk1.11.70.15-z.0_lu/bin/java
> /usr/lib/jvm/jdk1.17.0.11.0-openjdk/bin/java{code}
>  
> Depending on the host, Knox may start with Java 11 or Java 17.
> ----
> h3. *Proposed Fix*
>  * Extend {{JAVA_VERSION_PATTERNS}} to explicitly recognize Java 11 and Java 
> 17 layouts.
>  * Add support for {{/usr/java/default/bin/java}} to honor the system default 
> Java.
>  * Use {{find -L}} to follow symlinks.
>  * Sort Java candidates before selecting the first match to ensure 
> deterministic behavior.
> ----
> h3. *Impact*
> Ensures consistent Java version selection across all nodes in a cluster, 
> prevents unpredictable startup behavior, and aligns Knox Java discovery with 
> common enterprise JDK layouts.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to