cloudfoundry / php-buildpack

A Cloud Foundry Buildpack for PHP.
Apache License 2.0
142 stars 343 forks source link

PHP CA APM Agent not working with PHP>=8 #746

Open brayanhenao opened 1 year ago

brayanhenao commented 1 year ago

What version of Cloud Foundry and CF CLI are you using? (i.e. What is the output of running cf curl /v2/info && cf version?

{
   "name": "",
   "build": "",
   "support": "",
   "version": 0,
   "description": "",
   "authorization_endpoint": "https://login.vividorchid.cf-app.com",
   "token_endpoint": "https://uaa.vividorchid.cf-app.com",
   "min_cli_version": null,
   "min_recommended_cli_version": null,
   "app_ssh_endpoint": "ssh.vividorchid.cf-app.com:2222",
   "app_ssh_host_key_fingerprint": "yfKgdS2B0dh0j7LU2hPxgU/GjzhsDb53R2Wosdu8aCc",
   "app_ssh_oauth_client": "ssh-proxy",
   "doppler_logging_endpoint": "wss://doppler.vividorchid.cf-app.com:443",
   "api_version": "2.194.0",
   "osbapi_version": "2.15",
   "routing_endpoint": "https://api.vividorchid.cf-app.com/routing",
   "user": "bc1b5c2e-ac49-4750-aa21-ddfba90ec2b4"
}
cf version 7.5.0+0ad1d63.2022-06-04

What version of the buildpack you are using? https://github.com/cloudfoundry/php-buildpack/tree/a4b4b1e8ed800dfa35ba2d3aa20a578208a558d1 (Develop) candidate for next release (v4.5.0)

If you were attempting to accomplish a task, what was it you were attempting to do?

  1. Create a new user provided service with name caapm-test-something
  2. Push (without start) the content of this fixture (using the Buildpack version pointing to develop changes)
  3. Bind the service created with the app
  4. Check the logs

What did you expect to happen? Deploy a new app with the CA APM Agent configured

What was the actual behavior? CA APM PHP Agent not supporting PHP 8>=

Logs

Staging app and tracing logs...
   Cell 12148984-2ea2-4129-b5c7-80ab0de86e65 creating container for instance 0a3ded26-906b-4447-b7e5-07e41a0f4041
   Cell 12148984-2ea2-4129-b5c7-80ab0de86e65 successfully created container for instance 0a3ded26-906b-4447-b7e5-07e41a0f4041
   Downloading app package...
   Downloading build artifacts cache...
   Downloaded app package (176B)
   Downloaded build artifacts cache (218B)
   -------> Buildpack version 4.4.68
   Installing HTTPD
   HTTPD 2.4.54
   Downloaded [https://buildpacks.cloudfoundry.org/dependencies/httpd/httpd_2.4.54_linux_x64_cflinuxfs3_ebde532e.tgz] to [/tmp]
   Installing PHP
   PHP 8.1.13
   Downloaded [https://buildpacks.cloudfoundry.org/dependencies/php/php_8.1.13_linux_x64_cflinuxfs3_4a31f744.tgz] to [/tmp]
   Using the first CA APM service present in user-provided services
   Downloading CA APM PHP Agent package...
   Downloaded [https://packages.broadcom.com/artifactory/apm-agents/CA-APM-PHPAgent-20.11.0_linux.tar.gz] to [/tmp]
   Downloaded CA APM PHP Agent package
   Compiling CA APM PHP Agent install commands
   Installing CA APM PHP Agent
   Installing CA APM PHP Probe Agent...
   Installation Overview:
   1) PHP Root : /tmp/app/php/bin/php
   PHP Version : 8.1.13
   PHP Extensions directory : /tmp/app/php/lib/php/extensions/no-debug-non-zts-20210902
   PHP ini directory : /tmp/app/caapm
   Installation Status : Failed
   Reason : Unsupported version '8.1.13' of PHP found at /tmp/app/php/bin.
   Updating PHP INI file with CA APM PHP Agent Properties
   Traceback (most recent call last):
   File "/tmp/buildpackdownloads/6dcc476dbf761baf5f85ff0e6be3642b/scripts/compile.py", line 57, in <module>
   .from_build_pack('lib/additional_commands')
   File "/tmp/buildpackdownloads/6dcc476dbf761baf5f85ff0e6be3642b/lib/build_pack_utils/builder.py", line 212, in extensions
   process_extension(path, ctx, 'compile', process, args=[self])
   File "/tmp/buildpackdownloads/6dcc476dbf761baf5f85ff0e6be3642b/lib/build_pack_utils/utils.py", line 69, in process_extension
   success(getattr(extn, to_call)(*args))
   File "/tmp/buildpackdownloads/6dcc476dbf761baf5f85ff0e6be3642b/extensions/caapm/extension.py", line 244, in compile
   caapmphp._install_apm_agent()
   File "/tmp/buildpackdownloads/6dcc476dbf761baf5f85ff0e6be3642b/extensions/caapm/extension.py", line 214, in _install_apm_agent
   with open(caapm_ini, 'r') as caapm_php_ini:
   IOError: [Errno 2] No such file or directory: '/tmp/app/caapm/wily_php_agent.ini'
   Failed to compile droplet: Failed to run finalize script: exit status 1
   Exit status 223
   Cell 12148984-2ea2-4129-b5c7-80ab0de86e65 stopping instance 0a3ded26-906b-4447-b7e5-07e41a0f4041
   Cell 12148984-2ea2-4129-b5c7-80ab0de86e65 destroying container for instance 0a3ded26-906b-4447-b7e5-07e41a0f4041
Error staging application: BuildpackCompileFailed - App staging failed in the buildpack compile phase
FAILED

When manually downloading the CA APM Agent from https://packages.broadcom.com/artifactory/apm-agents/CA-APM-PHPAgent-20.11.0_linux.tar.gz and extracting the content:

cat installer.sh
...
...
...
# Get the version
  phpver=
  if [ -n "${havecfg}" ]; then
    phpver=`${phpdir}/php-config --version 2> /dev/null`
  elif [ -n "${havebin}" ]; then
   phpver=`${phpbin} -n -d display_errors=Off -d display_startup_errors=Off -d error_reporting=0 -r 'echo phpversion();' 2> /dev/null`
  fi

  if [ -z "${phpver}" ]; then
    loginfo "${phpdir} -> couldn't determine version"
    error="Could not determine the version of PHP located at ${phpdir}"
    logerror error
    return 1
  fi

  loginfo "${phpdir} -> Php Version=${phpver}"

  case "${phpver}" in
    5.3.*)
      ;;
    5.4.*)
      ;;
    5.5.*)
      ;;
    5.6.*)
      ;;
    7.0.*)
      ;;
    7.1.*)
      ;;
    7.2.*)
      ;;
    7.3.*)
      ;;
    7.4.*)
      ;;
    *)
      loginfo "${phpdir} -> unsupported version '${phpver}'"
      error="Unsupported version '${phpver}' of PHP found at ${phpdir}."
      logerror error
      return 1
      ;;
  esac

Please confirm where necessary:

johnnyr0x commented 1 year ago

move to icebox in case others report