From c75396581764801c75d3b5c083cc58e20eab9202 Mon Sep 17 00:00:00 2001 From: Michal Nowacki Date: Mon, 17 Apr 2023 09:55:25 -0400 Subject: [PATCH 1/8] ci: add test-agent workflow to test pull requests (#653) test-agent workflow replaces prototype agent-build workflow. test-agent workflow is capable of: - building daemon and running daemon unit tests - building agent (and axiom) for all supported platforms - building agent's (and axiom's) unit tests for all supported platforms - running agent's (and axiom's) unit tests for all supported platforms using valgrind as much as possible --- .github/docker/linux/pr_build.sh | 174 -------------------------- .github/docker/linux/release_build.sh | 11 -- .github/docker/linux/x64/Dockerfile | 108 ---------------- .github/docker/linux/x86/Dockerfile | 95 -------------- .github/workflows/agent-build.yml | 80 ------------ .github/workflows/test-agent.yml | 143 +++++++++++++++++++++ 6 files changed, 143 insertions(+), 468 deletions(-) delete mode 100755 .github/docker/linux/pr_build.sh delete mode 100755 .github/docker/linux/release_build.sh delete mode 100644 .github/docker/linux/x64/Dockerfile delete mode 100644 .github/docker/linux/x86/Dockerfile delete mode 100644 .github/workflows/agent-build.yml create mode 100644 .github/workflows/test-agent.yml diff --git a/.github/docker/linux/pr_build.sh b/.github/docker/linux/pr_build.sh deleted file mode 100755 index e259b03f5..000000000 --- a/.github/docker/linux/pr_build.sh +++ /dev/null @@ -1,174 +0,0 @@ -#!/bin/bash - -# -# Copyright 2020 New Relic Corporation. All rights reserved. -# SPDX-License-Identifier: Apache-2.0 -# - -# -# Build the daemon, agent and axiom tests in accordance with our pull request -# guidelines, which are documented in the README.md file. Additionally, run -# the axiom tests. -# -# This script is meant to run in GHA with the GitHub Pull Request -# action which handles reporting the outcome to GitHub for us. -# - -set -e -set -u - -die() { - echo - echo >&2 "FATAL: $*" - echo - exit 1 -} - -# -# Ensure /usr/local/bin should be in the PATH. -# -case ":$PATH:" in - *:/usr/local/bin:*) ;; - *) PATH=/usr/local/bin:$PATH -esac - -case ":$PATH:" in - *:/usr/local/go/bin:*) ;; - *) PATH=/usr/local/go/bin:$PATH -esac - -export PATH - - -# -# Set LD_LIBRARY_PATH -# -LD_LIBRARY_PATH=/usr/local/lib -export LD_LIBRARY_PATH - -# -# Get PHPS from the environment. -# - -PHPS=${PHP_VER} - -printf \\n -printf 'running daemon tests\n' -make -r -s daemon daemon_integration "ARCH=${ARCH}" - -# -# Limit valgrind to just the Linux builders. On Alpine Linux, valgrind -# appears to alter the results of floating point to string conversions -# causing spurious test failures. -# - -PHP_SAPIS=$(php-config --php-sapis) - -case $PHP_SAPIS in - *embed*) - PHP_SAPIS_EMBED=1 - ;; - *) - PHP_SAPIS_EMBED=0 - ;; -esac - -if [ "$(uname)" = Linux ] && [ ! -e /etc/alpine-release ] && [ $PHP_SAPIS_EMBED ]; then - do_valgrind=yes - printf \\n - printf 'grinding axiom tests\n' - make -r -j $(nproc) axiom-valgrind "ARCH=${ARCH}" -else - do_valgrind= - printf \\n - printf 'running axiom tests\n' - make -r -j $(nproc) axiom-run-tests "ARCH=${ARCH}" -fi - -# -# Run the agent integration tests without requiring any changes to the -# PHP installation, and (ideally) without the tests being negatively -# affected by any existing INI settings. For example, a pre-existing -# "extension = newrelic.so". For each version of PHP, override the INI -# file, INI directory and the extension directory using environment -# variables. -# - -INTEGRATION_DIR="${PWD}/integration.tmp" -if [ ! -d "$INTEGRATION_DIR" ]; then - mkdir "$INTEGRATION_DIR" - mkdir "${INTEGRATION_DIR}/etc" -fi - -rm -rf "${INTEGRATION_DIR:?}"/* - -export PHPRC="${INTEGRATION_DIR}/php.ini" -export PHP_INI_SCAN_DIR="${INTEGRATION_DIR}/etc" - -cat <"$PHPRC" -date.timezone = "America/Los_Angeles" -extension_dir = "${PWD}/agent/modules" -extension = "newrelic.so" -newrelic.loglevel = "verbosedebug" -EOF - -# -# Build a specific version of PHP and run unit and integration tests. -# -# If PHP with thread safety (ZTS) is enabled, build to ensure -# it compiles cleanly, but don't run the integration tests because -# (empirically) some PHP extensions are inconsistent with ZTS enabled leading -# to spurious failures that are not agent bugs. -# - - if [ -n "${LD_LIBRARY_PATH-}" ]; then - export LD_LIBRARY_PATH - fi - - printf \\n - printf "building agent (PHP=%s)\n" "$PHPS" - make agent-clean - make -r -j $(nproc) agent "ARCH=${ARCH}" - - - printf \\n - case "$PHPS" in - *8.0*) - printf "Skipping integration tests on PHP=%s while tests are under construction\n" "$PHPS" - ;; - *zts*) - printf "Skipping integration tests on ZTS (PHP=%s ZTS=enabled)\n" "$PHPS" - ;; - *) - printf "Running agent integration tests (PHP=%s ZTS=disabled)\n" "$PHPS" - printf "Temporarily disable integration tests in GHA while determining what to do with private keys.\n" - #make integration PHPS="$PHPS" "ARCH=${ARCH}" INTEGRATION_ARGS="--retry=1" - ;; - esac - printf \\n - - # - # Run the agent unit tests (just on Linux). - # - if [ "$(uname -s)" = 'Linux' ]; then - PHP_PREFIX=$(php-config --prefix) - - case $PHP_SAPIS in - *embed*) - if [ -n "$do_valgrind" ]; then - printf 'grinding agent unit tests\n' - make -r -j $(nproc) agent-valgrind "ARCH=${ARCH}" USER_LDFLAGS='-Wl,-z,muldefs' - else - printf 'running agent unit tests\n' - make -r -j $(nproc) agent-check "ARCH=${ARCH}" USER_LDFLAGS='-Wl,-z,muldefs' - fi - ;; - *) - printf 'skipping agent unit tests - embed SAPI not present\n' - ;; - esac - else - printf 'skipping agent unit tests - not Linux\n' - fi - - printf \\n # put a blank line diff --git a/.github/docker/linux/release_build.sh b/.github/docker/linux/release_build.sh deleted file mode 100755 index 750e61f1b..000000000 --- a/.github/docker/linux/release_build.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash - -# -# Copyright 2020 New Relic Corporation. All rights reserved. -# SPDX-License-Identifier: Apache-2.0 -# - -echo php $PHP_VER -echo arch $ARCH -make -j $(nproc) clean -make -r -j $(nproc) release-${PHP_VER}-gha "OPTIMIZE=1" "ARCH=${ARCH}" diff --git a/.github/docker/linux/x64/Dockerfile b/.github/docker/linux/x64/Dockerfile deleted file mode 100644 index 1927b58fb..000000000 --- a/.github/docker/linux/x64/Dockerfile +++ /dev/null @@ -1,108 +0,0 @@ -# -# Copyright 2020 New Relic Corporation. All rights reserved. -# SPDX-License-Identifier: Apache-2.0 -# - -# -# ARGs passed from GHA workflow. -# -ARG PHP_VER - -FROM php:${PHP_VER} - -RUN docker-php-source extract - -# -# Uncomment deb-src lines for all enabled repos. First part of single-quoted -# string (up the the !) is the pattern of the lines that will be ignored. -# Needed for apt-get build-dep call later in script -# -RUN sed -Ei '/.*partner/! s/^# (deb-src .*)/\1/g' /etc/apt/sources.list - -ARG DEBIAN_FRONTEND=noninteractive -RUN apt-get update -RUN apt-get install -y build-essential - -# -# PHP dependencies -# -RUN apt-get update \ - && apt-get -y install gcc git netcat \ - libpcre3 libpcre3-dev golang psmisc automake libtool \ - insserv procps vim ${PHP_USER_SPECIFIED_PACKAGES} \ - zlib1g-dev libmcrypt-dev - -# -# Other tools -# -RUN apt-get install -y gdb valgrind libcurl4-openssl-dev pkg-config libpq-dev libedit-dev libreadline-dev git - -# -# Install other packages. -# -RUN apt-get update && apt-get install -y \ - autoconf \ - autotools-dev \ - build-essential \ - bzip2 \ - ccache \ - curl \ - dnsutils \ - git \ - gyp \ - lcov \ - libc6 \ - libc6-dbg \ - libc6-dev \ - libgtest-dev \ - libtool \ - make \ - perl \ - strace \ - python-dev \ - python-setuptools \ - sqlite3 \ - libsqlite3-dev \ - openssl \ - libxml2 \ - libxml2-dev \ - libonig-dev \ - libssl-dev \ - unzip \ - wget \ - zip && apt-get clean - -# -# If the debian version is jessie or stretch, we need to install go manually; -# otherwise, we just install the golang package from the repository. -# go 1.11.6 matches the version that buster uses. -# -RUN if [ -z "$(grep '^10\.' /etc/debian_version)" ]; then \ - wget --quiet https://golang.org/dl/go1.11.6.linux-amd64.tar.gz -O- | tar -C /usr/local -zxvf -; \ - export GOROOT=/usr/local/go; \ - exportGOPATH="${HOME}/go"; \ - exportPATH="${GOPATH}/bin:${GOROOT}/bin:${PATH}"; \ - else \ - apt-get install -y golang; \ - fi - -# -# If the debian version is jessie, don't install argon2 -# -RUN if [ -z "$(grep '^8\.' /etc/debian_version)" ]; then \ - apt-get install -y argon2 libghc-argon2-dev; \ - fi - -# -# These args need to be repeated so we can propagate the VARS within this build context. -# -ARG PHP_VER -ARG ARCH -ARG BUILD_TYPE -ENV PHP_VER=${PHP_VER} -ENV ARCH=$ARCH -ENV BUILD_TYPE=$BUILD_TYPE - -COPY /.github/docker/linux/${BUILD_TYPE}_build.sh /build.sh - -ENTRYPOINT ["/build.sh"] diff --git a/.github/docker/linux/x86/Dockerfile b/.github/docker/linux/x86/Dockerfile deleted file mode 100644 index e9df49e4e..000000000 --- a/.github/docker/linux/x86/Dockerfile +++ /dev/null @@ -1,95 +0,0 @@ -# -# Copyright 2020 New Relic Corporation. All rights reserved. -# SPDX-License-Identifier: Apache-2.0 -# - -# -# Build args passed from GHA -# -ARG PHP_VER - -FROM i386/php:${PHP_VER} - -RUN docker-php-source extract - -# -# Uncomment deb-src lines for all enabled repos. First part of single-quoted -# string (up the the !) is the pattern of the lines that will be ignored. -# Needed for apt-get build-dep call later in script -# -RUN sed -Ei '/.*partner/! s/^# (deb-src .*)/\1/g' /etc/apt/sources.list - -ARG DEBIAN_FRONTEND=noninteractive -RUN apt-get update -RUN apt-get install -y build-essential - -# -# PHP dependencies -# -RUN apt-get update \ - && apt-get -y install gcc git netcat wget unzip \ - libpcre3 libpcre3-dev golang psmisc automake libtool \ - insserv procps vim ${PHP_USER_SPECIFIED_PACKAGES} - -RUN apt-get install -y default-libmysqlclient-dev libmcrypt-dev - -# -# Other tools -# - -RUN apt-get install -y curl gdb libcurl4-openssl-dev pkg-config postgresql libpq-dev libedit-dev libreadline-dev git - -# -# Install basic packages. -# -RUN apt-get update && apt-get install -y \ - autoconf \ - autotools-dev \ - golang \ - valgrind \ - libc6 \ - libc6-dbg \ - libc6-dev \ - libgtest-dev \ - libtool \ - make \ - perl \ - strace \ - python-dev \ - python-setuptools \ - python3-argon2 \ - sqlite3 \ - libsqlite3-dev \ - libghc-argon2-dev \openssl \ - libxml2 \ - libxml2-dev \ - libonig-dev \ - libssl-dev \ - zip && apt-get clean - -# -# C++ dependencies -# -RUN apt-get update && apt-get -y install libgflags-dev libgtest-dev libc++-dev clang && apt-get clean - -# -# Install packages for 32-bit compilation -# -RUN apt-get update && apt-get -y install gcc gcc-multilib g++ g++-multilib && apt-get clean - -RUN apt-get update - -# -# These args need to be repeated so we can propagate the VARS within this build context. -# - -ARG PHP_VER -ARG ARCH -ARG BUILD_TYPE -ENV PHP_VER=${PHP_VER} -ENV ARCH=$ARCH -ENV BUILD_TYPE=$BUILD_TYPE - -COPY /.github/docker/linux/${BUILD_TYPE}_build.sh /build.sh - -ENTRYPOINT ["/build.sh"] diff --git a/.github/workflows/agent-build.yml b/.github/workflows/agent-build.yml deleted file mode 100644 index 0bce2053d..000000000 --- a/.github/workflows/agent-build.yml +++ /dev/null @@ -1,80 +0,0 @@ -# Copyright 2020 New Relic Corporation. All rights reserved. -# SPDX-License-Identifier: Apache-2.0 -# - -# -# This is the workflow to do a PR build. -# - -name: agent-build - -# -# Controls when the action will run. -# -on: - # - # Triggers the workflow on push or pull request events but only for the main branch - # - push: - branches: - - main - - 'dev' - pull_request: - branches: - - main - - 'dev' - -jobs: - agent_pr: - env: - PHP_VER: ${{ matrix.php_ver }} - ARCH: ${{ matrix.arch }} - BUILD_TYPE: pr - OS: ${{ matrix.os }} - image_name: ${{ matrix.os }}:${{ matrix.php_ver }}${{ matrix.arch }} - runs-on: ubuntu-latest - strategy: - matrix: - os: [linux] - php_ver: ['7.0', '7.1-zts', '7.2', '7.3', '7.4', '8.0', '8.0-zts', '8.1', '8.1-zts', '8.2'] - arch: ['x64', 'x86'] - exclude: - # Excludes PHP 5.x, 7.x on linux 32-bit - # Excludes PHP 8.x as only 64bit is supported for these versions - - os: linux - php_ver: '7.0' - arch: 'x86' - - os: linux - php_ver: '7.1-zts' - arch: 'x86' - - os: linux - php_ver: '7.2' - arch: 'x86' - - os: linux - php_ver: '7.3' - arch: 'x86' - - os: linux - php_ver: '7.4' - arch: 'x86' - - os: linux - php_ver: '8.0' - arch: 'x86' - - os: linux - php_ver: '8.0-zts' - arch: 'x86' - - os: linux - php_ver: '8.1' - arch: 'x86' - - os: linux - php_ver: '8.1-zts' - arch: 'x86' - - os: linux - php_ver: '8.2' - arch: 'x86' - steps: - - name: Checkout Repo - uses: actions/checkout@v2 - - name: Build Custom Docker Image - run: docker build --build-arg ARCH=$ARCH --build-arg PHP_VER=$PHP_VER --build-arg BUILD_TYPE=$BUILD_TYPE -f ./.github/docker/${OS}/${ARCH}/Dockerfile -t $image_name . - - name: Build and Test - run: docker run --name runtest --workdir /github/workspace --rm -e GITHUB_WORKSPACE -e GITHUB_ENV -v "${GITHUB_WORKSPACE}":"/github/workspace" $image_name diff --git a/.github/workflows/test-agent.yml b/.github/workflows/test-agent.yml new file mode 100644 index 000000000..babdce7f2 --- /dev/null +++ b/.github/workflows/test-agent.yml @@ -0,0 +1,143 @@ +# Copyright 2020 New Relic Corporation. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 +# + +name: test-pull-request + +# +# Controls when the action will run. +# +on: + # + # Triggers the workflow on push or pull request events but only for listed branches + # + push: + branches: + - main + - 'dev' + pull_request: + branches: + - main + - 'dev' + - 'oapi' +jobs: + daemon-unit-tests: + runs-on: ubuntu-latest + env: + IMAGE_NAME: newrelic/nr-php-agent-builder + IMAGE_TAG: make-go + IMAGE_VERSION: v1 + strategy: + matrix: + platform: [gnu, musl] + arch: [amd64, arm64] + steps: + - name: Checkout newrelic-php-agent code + uses: actions/checkout@v3 + with: + path: php-agent + - name: Enable arm64 emulation + if: ${{ matrix.arch == 'arm64' }} + run: | + docker run --privileged --rm tonistiigi/binfmt --install arm64 + - name: Login to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Build daemon + run: > + docker run --rm --platform linux/${{matrix.arch}} + -v "${GITHUB_WORKSPACE}/php-agent":"/usr/local/src/newrelic-php-agent" + $IMAGE_NAME:$IMAGE_TAG-${{ matrix.platform }}-$IMAGE_VERSION daemon + - name: Run daemon tests + run: > + docker run --rm --platform linux/${{matrix.arch}} + -v "${GITHUB_WORKSPACE}/php-agent":"/usr/local/src/newrelic-php-agent" + $IMAGE_NAME:$IMAGE_TAG-${{ matrix.platform }}-$IMAGE_VERSION daemon_test + agent-unit-test: + runs-on: ubuntu-latest + env: + IMAGE_NAME: newrelic/nr-php-agent-builder + IMAGE_TAG: make-php + IMAGE_VERSION: v1 + strategy: + matrix: + platform: [gnu, musl] + arch: [amd64, arm64] + php: ['5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2'] + exclude: + - arch: arm64 + php: '5.5' + - arch: arm64 + php: '5.6' + - arch: arm64 + php: '7.0' + - arch: arm64 + php: '7.1' + - arch: arm64 + php: '7.2' + - arch: arm64 + php: '7.3' + - arch: arm64 + php: '7.4' + steps: + - name: Checkout Repo + uses: actions/checkout@v3 + with: + path: php-agent + - name: Enable arm64 emulation + run: | + docker run --privileged --rm tonistiigi/binfmt --install arm64 + - name: Login to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Determine if valgrind can be used + id: get-check-variant + run: | + if [[ ${{ matrix.platform }} = 'gnu' && ${{matrix.arch}} = 'amd64' ]]; then + echo "AXIOM_CHECK_VARIANT=valgrind" >> $GITHUB_OUTPUT + else + echo "AXIOM_CHECK_VARIANT=check" >> $GITHUB_OUTPUT + fi + if [[ ${{matrix.arch}} = 'arm64' ]]; then + echo "AGENT_CHECK_VARIANT=check" >> $GITHUB_OUTPUT + elif [[ ${{ matrix.platform }} = 'gnu' ]]; then + echo "AGENT_CHECK_VARIANT=valgrind" >> $GITHUB_OUTPUT + elif [[ ${{matrix.php}} = '5.5' || ${{matrix.php}} = '5.6' || ${{matrix.php}} = '7.0' || ${{matrix.php}} = '7.1' ]]; then + echo "AGENT_CHECK_VARIANT=check" >> $GITHUB_OUTPUT + else + echo "AGENT_CHECK_VARIANT=valgrind" >> $GITHUB_OUTPUT + fi + - name: Build axiom + run: > + docker run --rm --platform linux/${{matrix.arch}} + -v "${GITHUB_WORKSPACE}/php-agent":"/usr/local/src/newrelic-php-agent" + $IMAGE_NAME:$IMAGE_TAG-${{matrix.php}}-${{matrix.platform}}-$IMAGE_VERSION axiom + - name: Build agent + run: > + docker run --rm --platform linux/${{matrix.arch}} + -v "${GITHUB_WORKSPACE}/php-agent":"/usr/local/src/newrelic-php-agent" + $IMAGE_NAME:$IMAGE_TAG-${{matrix.php}}-${{matrix.platform}}-$IMAGE_VERSION agent + - name: Build axiom unit tests + run: > + docker run --rm --platform linux/${{matrix.arch}} + -v "${GITHUB_WORKSPACE}/php-agent":"/usr/local/src/newrelic-php-agent" + $IMAGE_NAME:$IMAGE_TAG-${{matrix.php}}-${{matrix.platform}}-$IMAGE_VERSION axiom-tests + - name: Run axiom unit tests + run: > + docker run --rm --platform linux/${{matrix.arch}} + -v "${GITHUB_WORKSPACE}/php-agent":"/usr/local/src/newrelic-php-agent" + $IMAGE_NAME:$IMAGE_TAG-${{matrix.php}}-${{matrix.platform}}-$IMAGE_VERSION axiom-${{ steps.get-check-variant.outputs.AXIOM_CHECK_VARIANT }} + - name: Build agent unit tests + run: > + docker run --rm --platform linux/${{matrix.arch}} + -v "${GITHUB_WORKSPACE}/php-agent":"/usr/local/src/newrelic-php-agent" + $IMAGE_NAME:$IMAGE_TAG-${{matrix.php}}-${{matrix.platform}}-$IMAGE_VERSION agent-tests + - name: Run agent unit tests + run: > + docker run --rm --platform linux/${{matrix.arch}} + -v "${GITHUB_WORKSPACE}/php-agent":"/usr/local/src/newrelic-php-agent" + $IMAGE_NAME:$IMAGE_TAG-${{matrix.php}}-${{matrix.platform}}-$IMAGE_VERSION agent-${{ steps.get-check-variant.outputs.AGENT_CHECK_VARIANT }} From a011b70057b6577cb1a88361a039ee8e8e27d4d5 Mon Sep 17 00:00:00 2001 From: Amber Sistla Date: Mon, 17 Apr 2023 08:34:54 -0700 Subject: [PATCH 2/8] chore(agent): Bump version to 10.10 (#656) --- VERSION | 2 +- axiom/nr_version.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/VERSION b/VERSION index fe6d2ac74..e8a306979 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -10.9.0 +10.10.0 diff --git a/axiom/nr_version.c b/axiom/nr_version.c index afe25c6b0..753701faf 100644 --- a/axiom/nr_version.c +++ b/axiom/nr_version.c @@ -37,8 +37,9 @@ * impatiens 13Feb2023 (10.6) * jasmine 08Mar2023 (10.7) * kalmia 27Mar2023 (10.8) + * lilac 05Apr2023 (10.9) */ -#define NR_CODENAME "lilac" +#define NR_CODENAME "marigold" const char* nr_version(void) { return NR_STR2(NR_VERSION); From cfb4bb9cb3f378c89c477504d489bc694ef94da1 Mon Sep 17 00:00:00 2001 From: Michal Nowacki Date: Wed, 26 Apr 2023 15:26:22 -0400 Subject: [PATCH 3/8] chore(install): Disable ZTS (#661) Don't check if zts binaries are in agent's install bundle. Abort installation on system with PHP with ZTS. Co-authored-by: Michael Fulbright --- agent/newrelic-install.sh | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/agent/newrelic-install.sh b/agent/newrelic-install.sh index f983df585..ddb2d068f 100755 --- a/agent/newrelic-install.sh +++ b/agent/newrelic-install.sh @@ -344,12 +344,6 @@ for pmv in "20121212" "20131226" "20151012" "20160303" "20170718" \ "20180731" "20190902" "20200930" "20210902" "20220829"; do check_file "${ilibdir}/agent/${arch}/newrelic-${pmv}.so" done -# remove following lines when ZTS removed from releases -# 8.2 does not ship with zts -for pmv in "20121212" "20131226" "20151012" "20160303" "20170718" \ -"20180731" "20190902" "20200930" "20210902"; do - check_file "${ilibdir}/agent/${arch}/newrelic-${pmv}-zts.so" -done if [ -n "${fmissing}" ]; then echo "ERROR: the following files could not be found:" >&2 @@ -1295,20 +1289,20 @@ does not exist. This particular instance of PHP will be skipped. fi log "${pdir}: pi_zts=${pi_zts}" -# uncomment when ZTS binaries are removed -# if [ "${pi_zts}" = "yes" ]; then -# msg=$( -# cat << EOF -# -#An unsupported PHP ZTS build has been detected. Please refer to this link: -# https://docs.newrelic.com/docs/apm/agents/php-agent/getting-started/php-agent-compatibility-requirements/ -#to view compatibilty requirements for the the New Relic PHP agent. -#The install will now exit. -#EOF -#) -# error "${msg}" -# exit 1 -# fi +# zts installs are no longer supported + if [ "${pi_zts}" = "yes" ]; then + msg=$( + cat << EOF + +An unsupported PHP ZTS build has been detected. Please refer to this link: + https://docs.newrelic.com/docs/apm/agents/php-agent/getting-started/php-agent-compatibility-requirements/ +to view compatibilty requirements for the the New Relic PHP agent. +The install will now exit. +EOF +) + error "${msg}" + exit 1 + fi # # This is where we figure out where to put the ini file, if at all. We only do From c21656f5af1afcae1479fe98a08ab20b08658220 Mon Sep 17 00:00:00 2001 From: Michal Nowacki Date: Thu, 27 Apr 2023 19:27:03 -0400 Subject: [PATCH 4/8] refactor: use GitHub Action to enable arm64 (#660) Use docker/setup-qemu-action to enable arm64 emulation and pin tonistiigi/binfmt image version. Use repository variable BINFMT_IMAGE_VERSION to control which version of this dependency will be used. --- .github/workflows/test-agent.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-agent.yml b/.github/workflows/test-agent.yml index babdce7f2..a4ab818ca 100644 --- a/.github/workflows/test-agent.yml +++ b/.github/workflows/test-agent.yml @@ -38,8 +38,10 @@ jobs: path: php-agent - name: Enable arm64 emulation if: ${{ matrix.arch == 'arm64' }} - run: | - docker run --privileged --rm tonistiigi/binfmt --install arm64 + uses: docker/setup-qemu-action@v2 + with: + image: tonistiigi/binfmt:${{vars.BINFMT_IMAGE_VERSION}} + platforms: arm64 - name: Login to Docker Hub uses: docker/login-action@v2 with: From b4c401f63b40da2dd648bf2aed185d168383ccf0 Mon Sep 17 00:00:00 2001 From: Michal Nowacki Date: Mon, 1 May 2023 19:42:48 -0400 Subject: [PATCH 5/8] feat: add support for installing on aarch64 systems (#663) Allow installing the agent on systems with aarch64 architecture with supported PHP versions: 8.0, 8.1 and 8.2. --- agent/newrelic-install.sh | 41 ++++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/agent/newrelic-install.sh b/agent/newrelic-install.sh index ddb2d068f..dddc29085 100755 --- a/agent/newrelic-install.sh +++ b/agent/newrelic-install.sh @@ -245,7 +245,7 @@ esac [ "${NR_INSTALL_ARCH}" = "x64" -o "${NR_INSTALL_ARCH}" = "x86_64" ] && arch="${NR_INSTALL_ARCH}" # exit if arch is unsupported -if [ "${arch}" != "x64" ]; then +if [ "${arch}" != "x64" ] && [ "${arch}" != "aarch64" ] ; then msg=$( cat << EOF @@ -257,18 +257,6 @@ EOF ) error "${msg}" - if [ "${arch}" = "aarch64" ]; then - cat << EOF - -In order to use the New Relic PHP Agent on the "aarch64" (also known as "ARM64") -architecture it is necessary to build the agent extension from sources. - -Instructions on how to build the agent are available here: - -https://docs.newrelic.com/docs/apm/agents/php-agent/installation/php-agent-installation-arm64/ - -EOF - fi echo "The install will now exit." exit 1 @@ -339,11 +327,22 @@ check_file "${ilibdir}/scripts/newrelic.ini.template" # MAKE SURE TO UPDATE THIS LIST WHENEVER SUPPORT IS ADDED OR REMOVED # FOR A PHP VERSION # Currently supported versions: -# (5.5, 5.6, 7.0, 7.1, 7.2, 7.3, 7.4, 8.0, 8.1, 8.2) +# (5.5, 5.6, 7.0, 7.1, 7.2, 7.3, 7.4) +# for x64 +if [ ${arch} = x64 ]; then for pmv in "20121212" "20131226" "20151012" "20160303" "20170718" \ -"20180731" "20190902" "20200930" "20210902" "20220829"; do +"20180731" "20190902"; do check_file "${ilibdir}/agent/${arch}/newrelic-${pmv}.so" done +fi +# Currently supported versions: +# (8.0, 8.1, 8.2) +# for x64 and aarch64 +if [ ${arch} = x64 ] || [ ${arch} = aarch64 ]; then + for pmv in "20200930" "20210902" "20220829"; do + check_file "${ilibdir}/agent/${arch}/newrelic-${pmv}.so" + done +fi if [ -n "${fmissing}" ]; then echo "ERROR: the following files could not be found:" >&2 @@ -1131,7 +1130,7 @@ Ignoring this particular instance of PHP. # Check if this is a supported arch # Should be caught on startup but add check here to be sure - if [ "${pi_arch}" != "x64" ]; then + if [ "${pi_arch}" != "x64" ] && [ "${pi_arch}" != "aarch64" ]; then msg=$( cat << EOF @@ -1158,6 +1157,16 @@ Ignoring this particular instance of PHP. return 1 fi + if [ "${pi_arch}" = "aarch64" ] && [ pi_php8 != "yes" ]; then + error "unsupported aarch64 version '${pi_ver}' of PHP found at: + ${pdir} +Ignoring this particular instance of PHP. +" + log "${pdir}: unsupported aarch64 version '${pi_ver}'" + unsupported_php=1 + return 1 + fi + log "${pdir}: pi_inidir_cli=${pi_inidir_cli}" log "${pdir}: pi_inifile_cli=${pi_inifile_cli}" From 4c393d4a2d5e432c3aa83ad17ed4204e51653128 Mon Sep 17 00:00:00 2001 From: bduranleau-nr <106178551+bduranleau-nr@users.noreply.github.com> Date: Tue, 9 May 2023 10:53:32 -0500 Subject: [PATCH 6/8] fix: typo in install-newrelic script (#666) Expand `pi_php8` variable correctly when checking aarch64 support. --- agent/newrelic-install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/agent/newrelic-install.sh b/agent/newrelic-install.sh index dddc29085..5b51b8d07 100755 --- a/agent/newrelic-install.sh +++ b/agent/newrelic-install.sh @@ -1157,7 +1157,7 @@ Ignoring this particular instance of PHP. return 1 fi - if [ "${pi_arch}" = "aarch64" ] && [ pi_php8 != "yes" ]; then + if [ "${pi_arch}" = "aarch64" ] && [ "${pi_php8}" != "yes" ]; then error "unsupported aarch64 version '${pi_ver}' of PHP found at: ${pdir} Ignoring this particular instance of PHP. From 94317663eb5fbca0486dc4c7c1310aaad0114509 Mon Sep 17 00:00:00 2001 From: bduranleau-nr <106178551+bduranleau-nr@users.noreply.github.com> Date: Thu, 18 May 2023 11:04:50 -0500 Subject: [PATCH 7/8] fix(agent): disable CAT when DT enabled (#658) ### Internally disable the global for CAT when both CAT and DT are enabled This PR will throw a warning message in the agent log about the CAT + DT conflict, suggest to the end user that they modify the setting, and will modify the `cross_process_enabled` INI value for the duration of the transaction to safeguard against any potential holes in the code that could allow both CAT and DT functionality present in the same transaction. This PR does not modify the INI file, and checking INI settings (with `phpinfo()` or `php -i`) will not show this change reflected. As far as I'm aware, that's only possible by modifying the INI file itself, which is not something we should do. A test has been added to verify this scenario. --- agent/php_minit.c | 19 ++++++ .../curl_exec/test_dt_enabled_cat_enabled.php | 68 +++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 tests/integration/external/curl_exec/test_dt_enabled_cat_enabled.php diff --git a/agent/php_minit.c b/agent/php_minit.c index 66dc70e1e..0980594f2 100644 --- a/agent/php_minit.c +++ b/agent/php_minit.c @@ -252,6 +252,23 @@ static nr_status_t nr_php_check_8T_DT_config(TSRMLS_D) { return NR_SUCCESS; } +static void nr_php_check_CAT_DT_config(TSRMLS_D) { + if (NRINI(distributed_tracing_enabled) && NRINI(cross_process_enabled)) { + // send a warning message to agent log + nrl_warning(NRL_INIT, + "Cross Application Tracing will be DISABLED because " + "Distributed Tracing is enabled. CAT functionality has been " + "superseded by DT and will be removed in a future release. The " + "New Relic PHP Agent Team suggests manually disabling CAT via " + "the 'newrelic.cross_application_tracer.enabled' INI setting " + "in your INI file and enabling DT via the " + "'newrelic.distributed_tracing_enabled' INI setting."); + + // set CAT INI value to disabled (just to be safe) + NRINI(cross_process_enabled) = 0; + } +} + /* * @brief Check the INI values for 'logging_enabled' and * 'log_forwarding_enabled' and log a warning on @@ -611,6 +628,8 @@ PHP_MINIT_FUNCTION(newrelic) { */ nr_php_check_8T_DT_config(TSRMLS_C); + nr_php_check_CAT_DT_config(TSRMLS_C); + nr_php_check_logging_config(TSRMLS_C); nr_php_check_high_security_log_forwarding(TSRMLS_C); diff --git a/tests/integration/external/curl_exec/test_dt_enabled_cat_enabled.php b/tests/integration/external/curl_exec/test_dt_enabled_cat_enabled.php new file mode 100644 index 000000000..3c2596f30 --- /dev/null +++ b/tests/integration/external/curl_exec/test_dt_enabled_cat_enabled.php @@ -0,0 +1,68 @@ + Date: Mon, 22 May 2023 17:36:25 -0400 Subject: [PATCH 8/8] ci(test-agent): use new make-php images (#667) `make` is no longer an entry point in enhanced make-php images. --- .github/workflows/test-agent.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test-agent.yml b/.github/workflows/test-agent.yml index a4ab818ca..f8de5df08 100644 --- a/.github/workflows/test-agent.yml +++ b/.github/workflows/test-agent.yml @@ -117,29 +117,29 @@ jobs: run: > docker run --rm --platform linux/${{matrix.arch}} -v "${GITHUB_WORKSPACE}/php-agent":"/usr/local/src/newrelic-php-agent" - $IMAGE_NAME:$IMAGE_TAG-${{matrix.php}}-${{matrix.platform}}-$IMAGE_VERSION axiom + $IMAGE_NAME:$IMAGE_TAG-${{matrix.php}}-${{matrix.platform}}-$IMAGE_VERSION make axiom - name: Build agent run: > docker run --rm --platform linux/${{matrix.arch}} -v "${GITHUB_WORKSPACE}/php-agent":"/usr/local/src/newrelic-php-agent" - $IMAGE_NAME:$IMAGE_TAG-${{matrix.php}}-${{matrix.platform}}-$IMAGE_VERSION agent + $IMAGE_NAME:$IMAGE_TAG-${{matrix.php}}-${{matrix.platform}}-$IMAGE_VERSION make agent - name: Build axiom unit tests run: > docker run --rm --platform linux/${{matrix.arch}} -v "${GITHUB_WORKSPACE}/php-agent":"/usr/local/src/newrelic-php-agent" - $IMAGE_NAME:$IMAGE_TAG-${{matrix.php}}-${{matrix.platform}}-$IMAGE_VERSION axiom-tests + $IMAGE_NAME:$IMAGE_TAG-${{matrix.php}}-${{matrix.platform}}-$IMAGE_VERSION make axiom-tests - name: Run axiom unit tests run: > docker run --rm --platform linux/${{matrix.arch}} -v "${GITHUB_WORKSPACE}/php-agent":"/usr/local/src/newrelic-php-agent" - $IMAGE_NAME:$IMAGE_TAG-${{matrix.php}}-${{matrix.platform}}-$IMAGE_VERSION axiom-${{ steps.get-check-variant.outputs.AXIOM_CHECK_VARIANT }} + $IMAGE_NAME:$IMAGE_TAG-${{matrix.php}}-${{matrix.platform}}-$IMAGE_VERSION make axiom-${{ steps.get-check-variant.outputs.AXIOM_CHECK_VARIANT }} - name: Build agent unit tests run: > docker run --rm --platform linux/${{matrix.arch}} -v "${GITHUB_WORKSPACE}/php-agent":"/usr/local/src/newrelic-php-agent" - $IMAGE_NAME:$IMAGE_TAG-${{matrix.php}}-${{matrix.platform}}-$IMAGE_VERSION agent-tests + $IMAGE_NAME:$IMAGE_TAG-${{matrix.php}}-${{matrix.platform}}-$IMAGE_VERSION make agent-tests - name: Run agent unit tests run: > docker run --rm --platform linux/${{matrix.arch}} -v "${GITHUB_WORKSPACE}/php-agent":"/usr/local/src/newrelic-php-agent" - $IMAGE_NAME:$IMAGE_TAG-${{matrix.php}}-${{matrix.platform}}-$IMAGE_VERSION agent-${{ steps.get-check-variant.outputs.AGENT_CHECK_VARIANT }} + $IMAGE_NAME:$IMAGE_TAG-${{matrix.php}}-${{matrix.platform}}-$IMAGE_VERSION make agent-${{ steps.get-check-variant.outputs.AGENT_CHECK_VARIANT }}