Browse code

Safety check for python version in get_pip_command

We know empirically that some legacy gate jobs pass and appear
to be running with python3 but actually pip was invoked with
PYTHON3_VERSION unset so that they are actually ran with python2
packages.

As a followup to this discussion [1], add a safety check in the
get_pip_command function to ensure that a python version has been
set when it is invoked.

[1] https://review.openstack.org/#/c/622415/4/inc/python@283

Change-Id: I3a08406fb7d68282c6b98abb33a625821510046a

Tom Barron authored on 2019/01/09 22:43:52
Showing 1 changed files
... ...
@@ -29,6 +29,10 @@ declare -A -g PROJECT_VENV
29 29
 # get_pip_command
30 30
 function get_pip_command {
31 31
     local version="$1"
32
+    if [ -z "$version" ]; then
33
+        die $LINENO "pip python version is not set."
34
+    fi
35
+
32 36
     # NOTE(dhellmann): I don't know if we actually get a pip3.4-python
33 37
     # under any circumstances.
34 38
     which pip${version} || which pip${version}-python