Skip to content

Commit

Permalink
Update Traffic Router Java version to 11 (#6210)
Browse files Browse the repository at this point in the history
* Update maven-pmd-plugin to 3.14.0, which uses PMD 6.29.0

* Update Java PMD rule names to their PMD 6 equivalents

* Unlist rules that are scheduled for removal in PMD 7

* Suppress PMD.CyclomaticComplexity and PMD.NPathComplexity

* Fix PMD warnings

* Set JAVA_HOME so Maven can find javac

* Rebuild the Traffic Router builder image if its Dockerfile was changed

* Use a fetch-depth of 4 to check files changed in the last 3 commits for the build-rpms GHA

* Update Traffic Router Java version to 11

* Do not set UseSplitVerifier, SplitVerifier is required in Java 11

* Resolve new CloseResource PMD failure in Java 11

* Use RSAPrivateCrtKey, RSAPrivateCrtKeyImpl is not visible in Java 11

* Decrease NPath complexity of DeliveryService constructor

* Do not escape '"'

* Commant and unabbreviate commit comparison

* Close resources in LetsEncryptDnsChallengeWatcher.readConfigFile()

* Do not close socket before handling the request

* Bind port to wildcard host for OpenJDK 11 compatibility

* Store socketWrapper socket for use after super.doRun()

* Fix PMD failures where all PMD failures were suppressed

* Remove temporary hack from #3392 that resolved an SSL issue in Tomcat

* Use OpenJDK 11 in Systemd service files

* Use OpenJDK 11 for Ansible Java HOME
  • Loading branch information
zrhoffman authored Dec 3, 2021
1 parent f39cda6 commit 31c4f96
Show file tree
Hide file tree
Showing 75 changed files with 895 additions and 974 deletions.
7 changes: 5 additions & 2 deletions .github/actions/build-rpms/build-rpms.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,12 @@ if [[ "$GITHUB_REF" == refs/pull/*/merge ]]; then
pr_number="$(<<<"$GITHUB_REF" grep -o '[0-9]\+')"
files_changed="$(curl "${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/pulls/${pr_number}/files" | jq -r .[].filename)"
else
files_changed="$(git diff-tree --no-commit-id --name-only -r "$GITHUB_SHA")"
files_changed="$(git diff --name-only HEAD~4 HEAD --)" # Files changed by the last 4 commits
fi
if <<<"$files_changed" grep '^GO_VERSION$'; then
if <<<"$files_changed" grep '^GO_VERSION$' ||
{ [[ "$ATC_COMPONENT" == traffic_router ]] &&
<<<"$files_changed" grep '^infrastructure/docker/build/Dockerfile-traffic_router$'; };
then
pkg_command+=(-b)
fi

Expand Down
3 changes: 2 additions & 1 deletion .github/actions/tr-unit-tests/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@
FROM alpine@sha256:08d6ca16c60fe7490c03d10dc339d9fd8ea67c6466dea8d558526b1330a85930

RUN apk add --no-cache \
openjdk8 \
openjdk11 \
maven \
tomcat-native

ENTRYPOINT cd traffic_router && \
export JAVA_HOME="$(command -v java | xargs realpath | xargs dirname)/.." && \
mvn "-Dmaven.repo.local=${GITHUB_WORKSPACE}/.m2/repository" \
test -Djava.library.path=/usr/share/java
4 changes: 4 additions & 0 deletions .github/workflows/cache-config-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 5
- name: Build RPM
uses: ./.github/actions/build-rpms
env:
Expand All @@ -86,6 +88,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 5
- name: Build RPM
uses: ./.github/actions/build-rpms
env:
Expand Down
18 changes: 18 additions & 0 deletions .github/workflows/ciab.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@master
with:
fetch-depth: 5
- name: Build RPM
uses: ./.github/actions/build-rpms
env:
Expand All @@ -101,6 +103,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@master
with:
fetch-depth: 5
- name: Build RPM
uses: ./.github/actions/build-rpms
env:
Expand All @@ -117,6 +121,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@master
with:
fetch-depth: 5
- name: Build RPM
uses: ./.github/actions/build-rpms
env:
Expand All @@ -133,6 +139,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@master
with:
fetch-depth: 5
- name: Cache node modules
uses: actions/cache@v2
with:
Expand All @@ -156,6 +164,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@master
with:
fetch-depth: 5
- name: Cache local Maven repository
uses: actions/cache@v2
with:
Expand All @@ -179,6 +189,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@master
with:
fetch-depth: 5
- name: Build RPM
uses: ./.github/actions/build-rpms
env:
Expand All @@ -195,6 +207,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@master
with:
fetch-depth: 5
- name: Build RPM
uses: ./.github/actions/build-rpms
env:
Expand All @@ -211,6 +225,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@master
with:
fetch-depth: 5
- name: Build RPM
uses: ./.github/actions/build-rpms
env:
Expand Down Expand Up @@ -268,6 +284,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@master
with:
fetch-depth: 5
- name: Cache Alpine Docker image
uses: actions/cache@v2
with:
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
### Fixed
- [#6197](https://github.com/apache/trafficcontrol/issues/6197) - TO `/deliveryservices/:id/routing` makes requests to all TRs instead of by CDN.
- Fixed Traffic Router crs/stats to prevent overflow and to correctly record the time used in averages.
- [#6209](https://github.com/apache/trafficcontrol/pull/6209) Updated Traffic Router to use Java 11 to compile and run
- [#5893](https://github.com/apache/trafficcontrol/issues/5893) - A self signed certificate is created when an HTTPS delivery service is created or an HTTP delivery service is updated to HTTPS.
- [#6125](https://github.com/apache/trafficcontrol/issues/6125) - Fix `/cdns/{name}/federations?id=#` to search for CDN.
- [#6255](https://github.com/apache/trafficcontrol/issues/6255) - Unreadable Prod Mode CDN Notifications in Traffic Portal
Expand Down
2 changes: 1 addition & 1 deletion docs/source/admin/quick_howto/ciab.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ The CDN in a Box directory is found within the Traffic Control repository at :fi
* Traffic Portal - at :file:`infrastructure/cdn-in-a-box/traffic_portal/traffic_portal.rpm`
* Traffic Router - at :file:`infrastructure/cdn-in-a-box/traffic_router/traffic_router.rpm` - also requires an Apache Tomcat RPM at :file:`infrastructure/cdn-in-a-box/traffic_router/tomcat.rpm`

.. note:: These can also be specified via the ``RPM`` variable to a direct Docker build of the component - with the exception of Traffic Router, which instead accepts ``JDK8_RPM`` to specify a Java Development Kit RPM, ``TRAFFIC_ROUTER_RPM`` to specify a Traffic Router RPM, and ``TOMCAT_RPM`` to specify an Apache Tomcat RPM.
.. note:: These can also be specified via the ``RPM`` variable to a direct Docker build of the component - with the exception of Traffic Router, which instead accepts ``TRAFFIC_ROUTER_RPM`` to specify a Traffic Router RPM and ``TOMCAT_RPM`` to specify an Apache Tomcat RPM.

These can all be supplied manually via the steps in :ref:`dev-building` (for Traffic Control component RPMs) or via some external source. Alternatively, the :file:`infrastructure/cdn-in-a-box/Makefile` file contains recipes to build all of these - simply run :manpage:`make(1)` from the :file:`infrastructure/cdn-in-a-box/` directory. Once all RPM dependencies have been satisfied, run ``docker-compose build --parallel`` from the :file:`infrastructure/cdn-in-a-box/` directory to construct the images needed to run CDN in a Box.

Expand Down
9 changes: 3 additions & 6 deletions docs/source/development/building.rst
Original file line number Diff line number Diff line change
Expand Up @@ -171,20 +171,20 @@ Install the Dependencies
| macOS\ [#mac-jdk]_ | - rpm | - go | - go | - npm | - maven | - go | - go | - go | - python3 |
| (homebrew_) | | | | - grunt-cli | | | | | |
+----------------------------+---------------------+----------------------------+------------------------+---------------------------+---------------------------+--------------------------+----------+------------------------------+--------------------------+
| CentOS\ [#centos-go]_, | - git | | | - epel-release | - java-1.8.0-openjdk | | | | - python3-devel |
| CentOS\ [#centos-go]_, | - git | | | - epel-release | - java-11-openjdk | | | | - python3-devel |
| Red Hat, | - rpm-build | | | - npm | - maven | | | | - gcc |
| Fedora | - rsync | | | - nodejs-grunt-cli | | | | | - make |
| (yum_) | | | | | | | | | |
+----------------------------+---------------------+----------------------------+------------------------+---------------------------+---------------------------+--------------------------+----------+------------------------------+--------------------------+
| Arch Linux, | - git | - go | - go | - npm | - jdk8-openjdk | - go | - go | - go | - python-pip |
| Arch Linux, | - git | - go | - go | - npm | - jdk11-openjdk | - go | - go | - go | - python-pip |
| Manjaro | - rpm-tools | | | - grunt-cli | - maven | | | | - python-sphinx |
| (pacman_) | - diff | | | | | | | | - make |
+----------------------------+---------------------+----------------------------+------------------------+---------------------------+---------------------------+--------------------------+----------+------------------------------+--------------------------+
| Windows | - git | | | | - curl | | | | |
| (cygwin_)\ [#windeps]_ | - rpm-build | | | | | | | | |
| | - rsync | | | | | | | | |
+----------------------------+---------------------+----------------------------+------------------------+---------------------------+---------------------------+--------------------------+----------+------------------------------+--------------------------+
| Windows | | - golang | - golang | - nodejs | - openjdk8 | - golang | - golang | - golang | - python |
| Windows | | - golang | - golang | - nodejs | - openjdk11 | - golang | - golang | - golang | - python |
| (chocolatey_)\ [#windeps]_ | | | | | - maven | | | | - pip |
| | | | | | | | | | - make |
+----------------------------+---------------------+----------------------------+------------------------+---------------------------+---------------------------+--------------------------+----------+------------------------------+--------------------------+
Expand All @@ -195,9 +195,6 @@ Install the Dependencies
.. _cygwin: https://cygwin.com/
.. _chocolatey: https://chocolatey.org/

.. |AdoptOpenJDK instructions| replace:: add the AdoptOpenJDK tap and install the ``adoptopenjdk8`` cask
.. _AdoptOpenJDK instructions: https://github.com/AdoptOpenJDK/homebrew-openjdk#other-versions

After installing the packages using your platform's package manager,

- Install the :ref:`global NPM packages <dev-tp-global-npm>` to build Traffic Portal.
Expand Down
18 changes: 6 additions & 12 deletions docs/source/development/traffic_router.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,35 +36,29 @@ To work on Traffic Router you need a \*nix (MacOS and Linux are most commonly us

* Eclipse >= Kepler SR2 (or another Java IDE)
* Maven >= 3.3.1
* JDK >= 8.0 (OpenJDK suggested, but not required)
* JDK >= 11 (OpenJDK suggested, but not required)
* OpenSSL >= 1.0.2
* :abbr:`APR (Apache Portable Runtime)` >= 1.4.8-3
* Tomcat Native >= 1.2.23
* Not Tomcat - You do not need a Tomcat installation for development. An embedded version is launched for development testing instead.

.. _dev-tr-mac-jdk:

Get OpenJDK 8 on macOS
Get OpenJDK 11 on macOS
--------------------------
If you are on macOS, OpenJDK 8 is not available from Homebrew by default, but it can still be installed using Homebrew with little effort.

Using Homebrew, |AdoptOpenJDK instructions|_
Using Homebrew:

.. code-block:: shell
:caption: Install OpenJDK 8 on macOS
:caption: Install OpenJDK 11 on macOS
brew tap AdoptOpenJDK/openjdk
brew cask install adoptopenjdk8
brew install openjdk@11
Next, set the JAVA_HOME environment variable. Add this line to your ``~/.bash_profile``:

.. code-block:: shell
:caption: Set JAVA_HOME environment variable
export JAVA_HOME=$(/usr/libexec/java_home -v1.8)
.. |AdoptOpenJDK instructions| replace:: add the AdoptOpenJDK tap and install the ``adoptopenjdk8`` cask
.. _AdoptOpenJDK instructions: https://github.com/AdoptOpenJDK/homebrew-openjdk#other-versions
export JAVA_HOME=$(/usr/libexec/java_home -v11)
Traffic Router Project Tree Overview
====================================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ tr_tomcat_base_dir: '/opt/tomcat'
tr_tomcat_logs_dir: "{{ tr_tomcat_base_dir }}/logs"

# JAVA_HOME to use in order to specify the desired JRE
tr_java_home_dir: '/usr/lib/jvm/jre'
tr_java_home_dir: '/usr/lib/jvm/jre-11-openjdk'

# Remove any locally cached copy of a CRConfig
tr_purge_crconfig_cache: False
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
- name: Install TR Dependencies
yum:
name:
- java-1.8.0-openjdk
- java-11-openjdk
- tomcat-native-1.2.23
state: present
update_cache: yes
Expand Down
4 changes: 2 additions & 2 deletions infrastructure/cdn-in-a-box/traffic_router/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ RUN dnf -y install epel-release && \
dnf -y install jq git rpm-build net-tools iproute nc wget tar unzip \
perl-JSON perl-WWW-Curl which make autoconf automake gcc gcc-c++ apr apr-devel \
openssl openssl-devel bind-utils net-tools perl-JSON-PP gettext \
java-1.8.0-openjdk-headless java-1.8.0-openjdk-devel tomcat-native && \
java-11-openjdk-headless java-11-openjdk-devel tomcat-native && \
dnf -y clean all && \
ln -sfv $(realpath /usr/lib/jvm/java-1.8.0) /opt/java
ln -sfv $(realpath /usr/lib/jvm/java-11) /opt/java

ADD $TRAFFIC_ROUTER_RPM /traffic_router.rpm
ADD $TOMCAT_RPM /tomcat.rpm
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/cdn-in-a-box/traffic_router/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ CATALINA_OPTS="\
-XX:InitiatingHeapOccupancyPercent=30"

if [[ "$TR_DEBUG_ENABLE" == true ]]; then
export JPDA_OPTS="-agentlib:jdwp=transport=dt_socket,address=5005,server=y,suspend=n";
export JPDA_OPTS="-agentlib:jdwp=transport=dt_socket,address=*:5005,server=y,suspend=n";
longer_dns_timeout;
fi;

Expand Down
4 changes: 2 additions & 2 deletions infrastructure/docker/build/Dockerfile-traffic_router
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ FROM common-dependencies AS traffic-router
RUN yum -y install \
which \
curl \
java-1.8.0-openjdk \
java-1.8.0-openjdk-devel && \
java-11-openjdk \
java-11-openjdk-devel && \
yum -y clean all

ENV JAVA_HOME=/usr/lib/jvm/java
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/docker/traffic_router/shutdowntr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
# TRAFFIC_MONITORS # list of semicolon-delimited FQDN:port monitors. E.g. `monitor.foo.com:80;monitor2.bar.org:80`
# ORIGIN_URI # origin server (e.g. hotair), used to create a delivery service

export JAVA_HOME=/usr/java/jdk1.8.0_92/jre
export JAVA_HOME="$(command -v java | xargs realpath | xargs dirname)/.."
export CATALINA_PID=/opt/traffic_router/temp/tomcat.pid
export CATALINA_HOME=/opt/tomcat
export CATALINA_BASE=/opt/traffic_router
Expand Down
2 changes: 1 addition & 1 deletion infrastructure/docker/traffic_router/starttr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
# Therefore it is important to keep this script up to date with any changes that are
# made to traffic_router/build/build_rpm.sh and traffic_router/build/pom.xml

export JAVA_HOME=/usr/java/jdk1.8.0_92/jre
export JAVA_HOME="$(command -v java | xargs realpath | xargs dirname)/.."
export CATALINA_PID=/opt/traffic_router/temp/tomcat.pid
export CATALINA_HOME=/opt/tomcat
export CATALINA_BASE=/opt/traffic_router
Expand Down
2 changes: 1 addition & 1 deletion traffic_router/build/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@
</mapping>
</mappings>
<requires>
<require>java >= 1.8</require>
<require>java-11</require>
<require>tomcat >= ${env.TOMCAT_VERSION}.${env.TOMCAT_RELEASE}</require>
<require>apr >= 1.4.8</require>
<require>tomcat-native >= 1.2.23</require>
Expand Down
Loading

0 comments on commit 31c4f96

Please sign in to comment.