xci: bifrost: Use 'sudo' to install dependencies for bifrost jobs 97/54897/1
authorMarkos Chandras <mchandras@suse.de>
Tue, 3 Apr 2018 17:09:32 +0000 (18:09 +0100)
committerMarkos Chandras <mchandras@suse.de>
Wed, 4 Apr 2018 09:55:12 +0000 (10:55 +0100)
When bifrost jobs are being executed, the virtual environment hasn't
been prepared yet because that's something that bifrost does later on.
As such, we need to use sudo to install the required dependencies to
avoid the following issue:

Exception:
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/usr/lib/python2.7/site-packages/pip/commands/install.py", line 342, in run
    prefix=options.prefix_path,
  File "/usr/lib/python2.7/site-packages/pip/req/req_set.py", line 784, in install
    **kwargs
  File "/usr/lib/python2.7/site-packages/pip/req/req_install.py", line 851, in install
    self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
  File "/usr/lib/python2.7/site-packages/pip/req/req_install.py", line 1064, in move_wheel_files
    isolated=self.isolated,
  File "/usr/lib/python2.7/site-packages/pip/wheel.py", line 345, in move_wheel_files
    clobber(source, lib_dir, True)
  File "/usr/lib/python2.7/site-packages/pip/wheel.py", line 316, in clobber
    ensure_dir(destdir)
  File "/usr/lib/python2.7/site-packages/pip/utils/__init__.py", line 83, in ensure_dir
    os.makedirs(path)
  File "/usr/lib64/python2.7/os.py", line 157, in makedirs
    mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/usr/lib/python2.7/site-packages/pbr'

Change-Id: I081884ec18d27af19a053bf5b734f6f3846c60f1
Signed-off-by: Markos Chandras <mchandras@suse.de>
xci/infra/bifrost/scripts/bifrost-provision.sh

index 2b849e3..95854e9 100755 (executable)
@@ -100,8 +100,10 @@ if [[ -e ${XCI_PATH}/deployment_image.qcow2 ]]; then
        sudo mv ${XCI_PATH}/deployment_image.qcow2* /httpboot/
 fi
 
-# Install missing dependencies
-pip install -q --upgrade -r "$(dirname $0)/../requirements.txt"
+# Install missing dependencies. Use sudo since for bifrost jobs
+# the venv is not ready yet.
+[[ -n ${VIRTUAL_ENV} ]] && _sudo="" || sudo="sudo -H -E"
+${_sudo} pip install -q --upgrade -r "$(dirname $0)/../requirements.txt"
 
 # Change working directory
 cd $BIFROST_HOME/playbooks