From ea57869d3e1ae899631f6d55b24f35c3d88b635d Mon Sep 17 00:00:00 2001 From: Tim Miller Date: Mon, 1 Apr 2013 14:55:15 -0700 Subject: [PATCH] Run all openstack services in virtualenvs: Python package dependency conflicts have been observed to occur for certain combinations of services at certain revision. Running all services in virtualenvs removes the issue. Change-Id: I100817569b43a5af3427b0ae20cebdc7d55d03a5 --- elements/os-svc-install/bin/os-svc-daemon | 5 ++- elements/os-svc-install/bin/os-svc-install | 31 +++++++++++++++---- .../pre-install.d/04-os-svc-install | 4 +++ 3 files changed, 33 insertions(+), 7 deletions(-) diff --git a/elements/os-svc-install/bin/os-svc-daemon b/elements/os-svc-install/bin/os-svc-daemon index 87c594610..11f737ae7 100755 --- a/elements/os-svc-install/bin/os-svc-daemon +++ b/elements/os-svc-install/bin/os-svc-daemon @@ -18,7 +18,10 @@ pre-start script end script respawn -exec sudo -u $user $cmd $args + +script + exec sudo -u $user /opt/stack/venvs/$user/bin/$cmd $args +end script EOF } diff --git a/elements/os-svc-install/bin/os-svc-install b/elements/os-svc-install/bin/os-svc-install index ebcb011a4..faa0de33e 100755 --- a/elements/os-svc-install/bin/os-svc-install +++ b/elements/os-svc-install/bin/os-svc-install @@ -4,9 +4,32 @@ set -eux pypi_mirror=http://pypi.openstack.org/ pip_install="pip install -i $pypi_mirror " + +function python-install() { + local name=$1 + local svc_root=$2 + + pushd /opt/stack/venvs + virtualenv --system-site-packages $name + popd + + set +u + source /opt/stack/venvs/$name/bin/activate + set -u + + [ -e $svc_root/tools/pip-requires ] && pip install -r $svc_root/tools/pip-requires + + $pip_install $svc_root + + set +u + deactivate + set -u +} + + function install-os-service() { local user=$1 - local repo=$2 + local repo=$(echo $2 | sed 's/github.com/review.openstack.org/') local branch=$3 id $user || useradd $user --system -d /var/run/$user -s /bin/false @@ -19,16 +42,12 @@ function install-os-service() { if [ ! -e $svc_root ]; then git clone --depth=1 -b $branch $repo $svc_root - - [ -e $svc_root/tools/pip-requires ] && pip install -r $svc_root/tools/pip-requires - $pip_install $svc_root + python-install $user $svc_root else if ! git $git_dir remote -v | grep $repo; then echo "ERROR: $svc_root exists and did not come from $repo" exit 1 fi - - # raise an error unless existing repo is at expected git-rev actual_rev=$(git $git_dir show | head -1 | awk '{print $2}') git $git_dir checkout $branch expected_rev=$(git $git_dir show | head -1 | awk '{print $2}') diff --git a/elements/os-svc-install/pre-install.d/04-os-svc-install b/elements/os-svc-install/pre-install.d/04-os-svc-install index 9fbb59020..0e91b6b0c 100755 --- a/elements/os-svc-install/pre-install.d/04-os-svc-install +++ b/elements/os-svc-install/pre-install.d/04-os-svc-install @@ -3,7 +3,11 @@ set -eux install-packages python-pip +pip install -U distribute # required by virtualenv +pip install virtualenv + install -m 0755 -o root -g root $(dirname $0)/../bin/os-svc-install /usr/local/bin/os-svc-install install -m 0755 -o root -g root $(dirname $0)/../bin/os-svc-daemon /usr/local/bin/os-svc-daemon install -m 0755 -o root -g root $(dirname $0)/../bin/os-db-create /usr/local/bin/os-db-create +install -m 0755 -o root -g root -d /opt/stack/venvs