From eb00095bca73abb354b8b0ea220e05fa31b3ea04 Mon Sep 17 00:00:00 2001 From: Pekka Enberg Date: Tue, 4 Jun 2019 20:54:34 +0300 Subject: [PATCH] relocate_python_scripts.py: Fix node-exporter install on Debian variants The relocatable Python is built from Fedora packages. Unfortunately TLS certificates are in a different location on Debian variants, which causes "node_exporter_install" to fail as follows: Traceback (most recent call last): File "/usr/lib/scylla/libexec/node_exporter_install", line 58, in data = curl('https://github.com/prometheus/node_exporter/releases/download/v{version}/node_exporter-{version}.linux-amd64.tar.gz'.format(version=VERSION), byte=True) File "/usr/lib/scylla/scylla_util.py", line 40, in curl with urllib.request.urlopen(req) as res: File "/opt/scylladb/python3/lib64/python3.7/urllib/request.py", line 222, in urlopen return opener.open(url, data, timeout) File "/opt/scylladb/python3/lib64/python3.7/urllib/request.py", line 525, in open response = self._open(req, data) File "/opt/scylladb/python3/lib64/python3.7/urllib/request.py", line 543, in _open '_open', req) File "/opt/scylladb/python3/lib64/python3.7/urllib/request.py", line 503, in _call_chain result = func(*args) File "/opt/scylladb/python3/lib64/python3.7/urllib/request.py", line 1360, in https_open context=self._context, check_hostname=self._check_hostname) File "/opt/scylladb/python3/lib64/python3.7/urllib/request.py", line 1319, in do_open raise URLError(err) urllib.error.URLError: Unable to retrieve version information node exporter setup failed. Fix the problem by overriding the SSL_CERT_FILE environment variable to point to the correct location of the TLS bundle. Message-Id: <20190604175434.24534-1-penberg@scylladb.com> --- scripts/relocate_python_scripts.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/scripts/relocate_python_scripts.py b/scripts/relocate_python_scripts.py index 60bd246137..c52e8d2e78 100755 --- a/scripts/relocate_python_scripts.py +++ b/scripts/relocate_python_scripts.py @@ -34,7 +34,15 @@ class FilesystemFixup: x="$(readlink -f "$0")" b="$(basename "$x")" d="$(dirname "$x")" -PYTHONPATH="${{d}}:${{d}}/libexec:$PYTHONPATH" PATH="${{d}}/{pythonpath}:${{PATH}}" exec -a "$0" "${{d}}/libexec/${{b}}" "$@" +CENTOS_SSL_CERT_FILE="/etc/pki/tls/cert.pem" +if [ -f "${{CENTOS_SSL_CERT_FILE}}" ]; then + c=${{CENTOS_SSL_CERT_FILE}} +fi +DEBIAN_SSL_CERT_FILE="/etc/ssl/certs/ca-certificates.crt" +if [ -f "${{DEBIAN_SSL_CERT_FILE}}" ]; then + c=${{DEBIAN_SSL_CERT_FILE}} +fi +PYTHONPATH="${{d}}:${{d}}/libexec:$PYTHONPATH" PATH="${{d}}/{pythonpath}:${{PATH}}" SSL_CERT_FILE="${{c}}" exec -a "$0" "${{d}}/libexec/${{b}}" "$@" ''' self.python_path = python_path self.installroot = installroot