datadog-agent icon indicating copy to clipboard operation
datadog-agent copied to clipboard

[omnibus] Set EXT_CFLAGS along with CFLAGS to build aerospike correctly

Open bkabrda opened this issue 3 years ago • 0 comments

What does this PR do?

Add EXT_CFLAGS as an environment variable when installing Python integrations and their dependencies.

Motivation

Python package aerospike that we install as dependency of the Aerospike integration has recently (since aerospike update from 6.0.0 to 6.1.2) been un-importable, raising the following error: ImportError: /opt/datadog-agent/embedded/lib/python3.8/site-packages/aerospike.cpython-38-x86_64-linux-gnu.so: undefined symbol: sk_pop_free. Upon investigation, a chain of events lead to this:

  • We use CentOS 6 builders.
  • In version 6.0.0, aerospike was distributing binary wheels in the manylinux2010 format, which covers CentOS 6, so pip would install the binary wheel.
  • In version 6.1.2, aerospike started distributing binary wheels in the manylinux2014 format, which no longer covers CentOS 6, so pip would install from tarball.
  • Installation from tarball would compile the sources during the installation. We set CFLAGS to be able to link against the embedded openssl, but aerospike C bindings don't respect this env variable - they only respect EXT_CFLAGS.
  • Because we didn't have EXT_CFLAGS defined, aerospike would compile against system openssl (which has an old version that only has symbol sk_pop_free.
  • In the Agent runtime, the aerospike C shared object would try to import symbols from our embedded openssl, which only has OPENSSL_sk_pop_free (because we use much never openssl version).
  • And hence the import error.

The fix is easy, we start setting EXT_CFLAGS to the same value as CFLAGS. Note that usage of EXT_CFLAGS, however uncommon, can be found out in the wild, so I think it's useful to set it for all builds to prevent such surprises in the future.

Additional Notes

Possible Drawbacks / Trade-offs

Describe how to test/QA your changes

Install the agent on CentOS 8/RHEL 8 and then either:

  • Run the aerospike integration and verify that it works fine or
  • Run /opt/datadog-agent/embedded/bin/python3 and try doing import aerospike - you should see no errors/exceptions

Reviewer's Checklist

  • [ ] If known, an appropriate milestone has been selected; otherwise the Triage milestone is set.
  • [ ] Use the major_change label if your change either has a major impact on the code base, is impacting multiple teams or is changing important well-established internals of the Agent. This label will be use during QA to make sure each team pay extra attention to the changed behavior. For any customer facing change use a releasenote.
  • [ ] A release note has been added or the changelog/no-changelog label has been applied.
  • [ ] Changed code has automated tests for its functionality.
  • [ ] Adequate QA/testing plan information is provided if the qa/skip-qa label is not applied.
  • [ ] At least one team/.. label has been applied, indicating the team(s) that should QA this change.
  • [ ] If applicable, docs team has been notified or an issue has been opened on the documentation repo.
  • [ ] If applicable, the need-change/operator and need-change/helm labels have been applied.
  • [ ] If applicable, the k8s/<min-version> label, indicating the lowest Kubernetes version compatible with this feature.
  • [ ] If applicable, the config template has been updated.

bkabrda avatar Aug 10 '22 12:08 bkabrda