[ 
https://issues.apache.org/jira/browse/YETUS-913?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16930466#comment-16930466
 ] 

Allen Wittenauer edited comment on YETUS-913 at 9/16/19 11:54 AM:
------------------------------------------------------------------

The problem here is one of consistency.  If someone defines a known env var 
(e.g., MAVEN_OPTS), it follows the exact same pattern:  test-patch assumes it 
is for it and pulls it into the container, overriding whatever is there.  This 
also means that one can build a docker image with multiple JDKs and use the 
JAVA_HOME var to pick which one to use.  Things also get tricky when one 
considers what '--java-home' does.

An easier fix is for users to not set JAVA_HOME before calling test-patch.  
Which makes

bq.  This includes when the host doesn't define a JAVA_HOME, effectively 
preventing a JAVA_HOME set by the image (either via ENV or by installing some 
package that sets it).

a bug.


was (Author: aw):
The problem here is one of consistency.  If someone defines a known env var 
(e.g., MAVEN_OPTS), it follows the exact same pattern:  test-patch assumes it 
is for it and pulls it into the container, overriding whatever is there.  This 
also means that one can build a docker image with multiple JDKs and use the 
JAVA_HOME var to pick which one to use.  Things also get tricky when one 
considers what '--java-home' does.

An easier fix is for users to not set JAVA_HOME before calling test-patch.

> Docker mode pre-commit can't use JAVA_HOME defined in dockerfile
> ----------------------------------------------------------------
>
>                 Key: YETUS-913
>                 URL: https://issues.apache.org/jira/browse/YETUS-913
>             Project: Yetus
>          Issue Type: Bug
>          Components: Precommit
>    Affects Versions: 0.9.0, 0.10.0, 0.11.0
>            Reporter: Sean Busbey
>            Priority: Major
>
> Over in HBase we use different JDKs depending on the branch, due to our 
> compatibility promises in major release lines. For test-patch runs, this 
> changes the set of JDKs we install in each branch's Dockerfile.
> While recently trying to chase down why we were getting JDK8 used to test a 
> branch that's JDK7+, I realized that the docker bootstrapping _always_ 
> overwrites the JAVA_HOME in the image with JAVA_HOME on the host. This 
> includes when the host doesn't define a JAVA_HOME, effectively preventing a 
> JAVA_HOME set by the image (either via ENV or by installing some package that 
> sets it).
> Workaround:
> You can prevent this by replacing the {{docker_do_env_adds}} function in your 
> personality. e.g. this version will only set JAVA_HOME in the docker instance 
> if the host defines it. We then make sure all of our uses of test-patch unset 
> JAVA_HOME before invocation.
> {code}
> # work around yetus overwriting JAVA_HOME from our docker image
> function docker_do_env_adds
> {
>   declare k
>   for k in "${DOCKER_EXTRAENVS[@]}"; do
>     if [[ "JAVA_HOME" == "${k}" ]]; then
>       if [ -n "${JAVA_HOME}" ]; then
>         DOCKER_EXTRAARGS+=("--env=JAVA_HOME=${JAVA_HOME}")
>       fi
>     else
>       DOCKER_EXTRAARGS+=("--env=${k}=${!k}")
>     fi
>   done
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.3.2#803003)

Reply via email to